How to use the Media Player launcher for Windows Phone 8
July 21, 2014
Applies to: Windows Phone 8 and Windows Phone Silverlight 8.1 | 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 8.
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.