9 out of 18 rated this helpful - Rate this topic

How to play or stream a video file for Windows Phone 8

April 14, 2014

Applies to: Windows Phone 8 and Windows Phone Silverlight 8.1 | Windows Phone OS 7.1

You can play media files on a Windows Phone using the MediaPlayerLauncher, or for a more customized experience, you can use the MediaElement class.

To play a local video file using the MediaElement API

  1. Open a new or existing solution in Visual Studio.

  2. Right-click the name of your project in the Solution Explorer, click Add, and then click Existing Item.

  3. Navigate to an existing video file and add it to the project. In the Properties window, .set the Build Action to Content

    NoteNote:

    The video must be encoded with a codec listed in Supported media codecs for Windows Phone 8.

  4. In the ContentGrid section of the XAML code, add the following line:

    <MediaElement Source="test.wmv" AutoPlay="True"/>
    
    
    

    Replace test.wmv with the name of your video file.

To play a remote video file using the MediaElement API

  1. Open a new or existing solution in Visual Studio.

  2. In the ContentGrid section of the XAML code, add the following line:

    <MediaElement Source="http://mschannel9.vo.msecnd.net/o9/mix/09/wmv/key01.wmv" AutoPlay="True"/>
    
    

    Replace the value of Source with the location of the remote video file.

    NoteNote:

    The video must be encoded with a codec listed in Supported media codecs for Windows Phone 8.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.