How to use the Media Player launcher for Windows Phone
December 04, 2013
Applies to: Windows Phone 8 | Windows Phone OS 7.1
Use the Media Player Launcher to start the media player and play the media file you specify. You must specify the name and location of the file. You can optionally specify one or more of the Media Player controls, such as rewind and stop, by using a bitwise combination of the controls. You can also specify a preferred orientation to use when the Media Player starts.
By using Launchers, you help provide a consistent user experience throughout the Windows Phone platform. For more information, see Launchers and Choosers for Windows Phone.
On Windows Phone Emulator, the application can start the Media Player and the user can play music, but video is not rendered.
To use the Media Player Launcher
Add the following statements to your code.
Add the following code to your application wherever you need it, such as in a button click event. To test this procedure, you can put the code in the page constructor. This is the code to launch the task.
MediaPlayerLauncher mediaPlayerLauncher = new MediaPlayerLauncher(); mediaPlayerLauncher.Media = new Uri("MyVideo.wmv", UriKind.Relative); mediaPlayerLauncher.Location = MediaLocationType.Data; mediaPlayerLauncher.Controls = MediaPlaybackControls.Pause | MediaPlaybackControls.Stop; mediaPlayerLauncher.Orientation = MediaPlayerOrientation.Landscape; mediaPlayerLauncher.Show();
Use MediaLocationType.Data for media files that are stored in isolated storage. Use MediaLocationType.Install for media files that are part of the application project. They are bundled into the .xap file and stored in the installation directory of the application.