Microsoft Media Platform on Windows Phone 7 and fast resume

The Microsoft Media Platform: Player Framework is the player of choice for the Windows Phone 7, if you want to do anything with media in your application. For the Channel9 Client for Windows Phone 7 I have used it in combination with the IIS Smooth Streaming Client 1.5 plugin, as Channel9 provides excellent streams for their most popular videos.

To use the player is very straightforward;

  • Download the binaries from Codeplex
  • Download the IIS Smooth Streaming Client 1.5
  • Reference the assemblies
  • Place the player on your page

It’s that simple!

However, there are a couple of gotcha’s that I ran into while using this player;

MEF

It uses MEF to discover plugins that you may have distributed in your XAP file. That’s awesome, but if one if your assemblies contains an error (in my case the Silverlight 4 version of HTMLAgilityPack) it stops working. This is frustrating, because I did not think to look at other assemblies then the assemblies of the player framework. Took me some time to figure it out.

Fast Resume

With the Mango release of Windows Phone 7 it is possible to implement fast resume. I ran into a curious bug, feature or a bad implementation from my side when I tried to fast resume a video. It would not start playing the video and pressing the play button gives an unhandled exception.

I ended up implementing the following code, because I have no idea what is going on and no clue how to solve the issue.

namespace Channel9.Views
{
    public partial class PlayerView : PhoneApplicationPage
    {
        private bool isInitialized = false;
        private int refreshCount = 0;

        public PlayerView()
        {
            InitializeComponent();
            isInitialized = true;
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var entry = NavigationService.BackStack.FirstOrDefault();
            if (entry != null && entry.Source.ToString().Contains("PlayerView.xaml"))
            {
                NavigationService.RemoveBackEntry();
            }
            if</span> (!isInitialized)
            {
                refreshCount++;
                NavigationService.RemoveBackEntry();
                NavigationService.Navigate(new Uri(String.Format("/Views/PlayerView.xaml?refresh={0}", refreshCount), UriKind.RelativeOrAbsolute));
            }
            isInitialized = false;
        }
    }
}

If any of my reader(s) (hi Panfilov!) knows how to solve the issue, please leave a comment.

Next time, I will post an update to the HTMLTextBlock and dive into the DelayLoadImageWithCachingControl (might be filed under a different name).

Advertisements

~ by Matthijs Krempel on March 15, 2012.

One Response to “Microsoft Media Platform on Windows Phone 7 and fast resume”

  1. It’s very straightforward to find out any matter on net as compared to books, as
    I found this article at this web page.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: