Show PosterSource image whilst playing audio?

Topics: Windows 8 Xaml
Apr 7, 2013 at 7:53 PM
Is it possible to have the Poster image displayed permanently to cater for audio only scenarios?

I use the framework to play a mix of video and audio content, and I know I can use the mediaPlayer.IsAudioOnly property to know which is which, but if I am only playing audio I would want to display an image (Poster) for the duration of this file.

Is this already possible and I've just missed something?
Coordinator
Apr 9, 2013 at 12:23 AM
I like the idea. Unfortunately, we don't have an out-of-the box feature like this but there are definitely ways to accomplish this. For example, if you set the PosterSource property, and run the following code, it should do what you are after:
Border posterContainer;

public MainPage()
{
    this.InitializeComponent();
    player.Initialized += player_Initialized;
    player.MediaOpened += player_MediaOpened;
}

void player_MediaOpened(object sender, RoutedEventArgs e)
{
    if (player.IsAudioOnly)
    {
        posterContainer.Child = new Image() { Source = player.PosterSource };
    }
    else
    {
        posterContainer.Child = null;
    }
}

void player_Initialized(object sender, RoutedEventArgs e)
{
    var mediaContainer = player.Containers.OfType<Panel>().FirstOrDefault(c => c.Name == MediaPlayerTemplateParts.MediaContainer);
    posterContainer = new Border();
    mediaContainer.Children.Add(posterContainer);
}
Apr 9, 2013 at 1:03 PM
That worked a charm, thank you.