Playback

Of course, the most common thing to do with audio and video is to play it. There is one element for doing this, and it’s appropriately called MediaElement. MediaElement is a UIElement that displays a video (and plays its audio) much like Image displays image content. It plays audio-only files, too, so MediaElement is the XAML analog to HTML’s audio and video tags rolled into one.

You can set MediaElement’s source to a Uri that points an audio or video file, for example:

<MediaElement Source="Assets/video.mp4"/>

When you set MediaElement’s Source, the content is fetched asynchronously, and then either a MediaOpened or MediaFailed event gets raised.

All the Uri options discussed in Chapter 11, “Images,” apply ...

Get XAML 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.