PlaylistPlugin.Playlist is not bindable

Topics: Windows 8 Xaml
Jun 11, 2012 at 11:33 AM

PlaylistPlugin.Playlist is not bindable – i.e. this doesn’t work:

<mmppf:MediaPlayer Name="Player">

<mmppf:MediaPlayer.Plugins>

               <adaptive:AdaptivePlugin />

               <mmppf:PlaylistPlugin Playlist="{Binding MyPlaylist}" />

</mmppf:MediaPlayer.Plugins>

</mmppf:MediaPlayer>

 

We have to set the Playlist explicitly

((PlaylistPlugin)Player.Plugins.Single(p => p.GetType() == typeof(PlaylistPlugin))).Playlist = …

 

 Will this change on future releases?

Coordinator
Jun 12, 2012 at 6:05 PM

I've been able to confirm the issue. Thanks for reporting this, I'll try to get this addressed for the next update.

Coordinator
Jun 12, 2012 at 6:41 PM
Edited Jun 12, 2012 at 6:41 PM

It turns out, DataContext is not passed along to children of collection properties in Win8 Xaml and this is causing the issue. I'm not sure if this is a Win8 bug or expected behavior. However, here is a fairly easy way to bind to the playlist that works today...

    <Page.Resources>
        <local:vm x:Key="vm"/>
    </Page.Resources>
    <Grid Style="{StaticResource LayoutRootStyle}">
        <mmppf:MediaPlayer x:Name="player" IsSkipPreviousVisible="True" IsSkipNextVisible="True">
            <mmppf:MediaPlayer.Plugins>
                <mmppf:PlaylistPlugin Playlist="{Binding Playlist, Source={StaticResource vm}}"/>
            </mmppf:MediaPlayer.Plugins>
        </mmppf:MediaPlayer>
    </Grid>

public class vm
{
    public ObservableCollection<PlaylistItem> Playlist
    {
        get
        {
            return new ObservableCollection<PlaylistItem>(new[] { 
            new PlaylistItem() { Source = new Uri("http://smf.blob.core.windows.net/samples/videos/bigbuck.mp4") },
            new PlaylistItem() { Source = new Uri("http://smf.blob.core.windows.net/samples/videos/wildlife.mp4") },
            });
        }
    }
}

 

Jun 12, 2012 at 10:24 PM

Thank you!

Sep 13, 2013 at 10:48 PM
Hi,
I am having setting the playlist explicitly and then playing it. Even though I set it though code. I can set the playlist using the same code as above but it does not play. Any help will be appreciated.

Thanks,
Naveed
Coordinator
Sep 16, 2013 at 6:17 PM
@naveedzaheer, it may be a timing issue. If you set the playlist after or during the Initialized event, you need to also manually set CurrentPlaylistItem in order to cause the playlistitem to be loaded. If you set the playlist collection before Initialized, the first playlistitem should get automatically loaded.