The Media Content

MediaElement has a SetSource method just like BitmapSource’s method seen in the preceding chapter, so you can easily initialize it with an IRandomAccessStream that comes from a variety of sources, such as a file that a user retrieves from the file picker or files that you programmatically retrieve from the user’s Videos library. However, MediaElement’s SetSource method also requires you to pass the relevant MIME type (as a string) in order to determine the format of the media file. For a video stream, this would be a string such as video/mp4, video/x-ms-asf, or video/x-ms-wmv. For an audio stream, this would be a string such as audio/mp3 or audio/x-ms-wma. Fortunately, every StorageFile exposes its MIME type via its ContentType ...

Get Universal Windows® Apps with XAML and C# 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.