MediaStreamSource sample for Silverlight| Comments
You may be reading the title and wondering what is MediaStreamSource? MediaStreamSource is a piece of the Silverlight runtime that removes a the influence of a media file's container, giving developers direct access to APIs for manipulating encoded elementary audio and video streams.
Basically it can enable you as the developer to implement file parsers/etc. in managed code instead of Silverlight, enabling support beyond the native built-in formats for media. There hasn’t been much information about these types of topics, and I’d agree that for the mainstream, they may be a bit more advanced media scenarios for when the default containers and formats aren’t enough for your use. Outside of the MSDN documentation there hasn’t really been any good samples of this use either.
One of the program managers on the Silverlight media team, Larry Olson, has just provided a detailed public sample of the MediaStreamSource in action on the MSDN Code Gallery site. He calls the effort ManagedMediaHelpers. The project contains:
- Silverlight class library (MediaParsers) which has helper classes for working with MP3 files, including being able to find the right point in an MP3 to begin playback.
- Silverlight test project for NUnit
- Silverlight class library (Mp3MediaStreamSource) which has logic for using MP3 file streams
- Silverlight Application Demo which shows the interaction between a MediaElement and a MediaStreamSource
Why would you want this? Larry outlines in the project:
“For one thing, having access to elementary streams means that developers can now implement scenarios that other solutions haven't necessarily provided thus far. One example of this is adaptive streaming or multi-bitrate support as was seen during the 2008 Olympics.
For another reason, having access to elementary streams allows developers to implement scenarios that the Silverlight runtime hasn't had a chance to implement yet or that the runtime might not be able to implement in the same timeframe that a developer wants it. Examples of this could be, RTSP:T protocol support, SHOUTcast protocol support, seamless audio looping, ID3 v1 and ID3 v2 metadata support, and many other scenarios.”
This is a great sample and source for those working with media within Silverlight. Right now it is audio only, MP3 support, but gives you an idea of the MediaStreamSource API and functionality you could implement.
Please enjoy some of these other recent posts...