Playing Audio and Video with the MediaElement

MediaElement allows you to play audio and video from a file located in the app’s XAP file, from isolated storage, or by streaming it from a remote location. MediaElement is a FrameworkElement that provides a rectangular region used for displaying video on its surface.

To show video content in your app, place the MediaElement markup where you want the video to be displayed, as shown in the following example:

<MediaElement Source="http://www.example.net/Video.wmv" />

After the MediaElement is loaded, it begins to download and play the content.

Note

The XNA SoundEffect class is better suited to playing short sound effects. There can be a slight delay when first playing a sound using the MediaElement ...

Get Windows® Phone 8 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.