Playing Custom Media Formats

You can plug custom behavior into the media pipeline with a class called MediaStreamSource from the Windows.Media.Core namespace. To do this, you:

1. Configure an instance of MediaStreamSource with encoding information about the audio and/or video data you’re going to produce

2. Tell the MediaStreamSource how long the media will be by setting its Duration property

3. Provide a callback with which you will deliver the audio samples by attaching a handler to its SampleRequested event

4. Set the MediaStreamSource as the source of a MediaElement by passing it to MediaElement’s SetMediaStreamSource method instead of SetSource

MediaStreamSource would be typically used to retrieve existing media, perhaps via a custom mechanism, ...

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.