O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required