How to: Play or Stream a Video File for Windows Phone
March 22, 2012
You can play media files on a Windows Phone using the MediaPlayerLauncher, or for a more customized experience, you can use the MediaElement API.
Before using the MediaElement API, learn about differences between the desktop version here: Media for Silverlight for Windows Phone.
To play a local video file using the MediaElement API
-
Open a new or existing solution in Visual Studio.
-
Right-click the name of your project in the Solution Explorer, click Add, and then click Existing Item.
-
Navigate to an existing video file and add it as Build Action type Content, in the Properties window.
The video must be encoded with a codec listed in Supported Media Codecs for Windows Phone.
-
In the ContentGrid section of the .xaml code, add the following line:
Replace test.wmv with the name of your video file.
To play a remote video file using the MediaElement API
-
Open a new or existing solution in Visual Studio.
-
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 Source value with the location of the remote video file.

The video must be encoded with a codec listed in Supported Media Codecs for Windows Phone.