Search Wiki:
Resource Page Description
Two Silverlight class libraries and an example Silverlight Application to jump start development with and learning about Silverlight's MediaStreamSource.

Why ?
This project grew out of 3 desires:
  1. Provide a MediaStreamSource sample that is useful for educating developers on development with Silverlight's MediaStreamSource
  2. Provide helper classes which make it easier to use MediaStreamSource for certain scenarios (Mp3 for now)
  3. Prime the Silverlight development community with MediaStreamSource code to see what creative things can be built

What is in this project ?
This project contains 4 things.
  1. A Silverlight class library, MediaParsers, which contains helper classes for working with Mp3 files, including tools to help find the right point in an Mp3 file to begin playback from and Managed implementations of fundamental media structures.
  2. A Silverlight Test Project built for nunit, MediaParsersTests, which provides core code coverage for the MediaParsers library.
  3. A Sliverlight class library, Mp3MediaStreamSource, which has arguably the simplest logic imaginable for using Mp3 file streams with a MediaStreamSource.
  4. A Sliverlight Application demo, Mp3MediaStreamSourceDemo and Mp3MediaStreamSourceDemoWeb, which shows the simplest interaction between a MediaElement and a MediaStreamSource.

What is a MediaStreamSource ?
The 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.

Why would anyone want to remove the container ?
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.

Tools used by this project
Visual Studio 2008 Professional
Nunit
Silverlight Nunit Project Template
FxCop
StyleCop

Who are you?
Larry Olson
Blog
Last edited Sep 27 2008 at 8:25 AM  by loarabia, version 11
Comments
pdjplanonuance wrote  Mar 24 at 6:22 PM  
I am loading a mp3 file just fine using new Uri but when i try to load the exact same file using this library, it doesn't appear to work. I'm stuffing the .mp3 into isolated storage (via file copy manually to test) and it loads the file fine, but when i'm calling SetSource() it appears to think it's a very long audio file but nothing is playing back in the MediaElement. Is there a restriction on the type of .mp3 file format this library can actually load/process???

TIA, paul

loarabia wrote  Apr 6 at 6:17 PM  
Mp3 files with some metadata (ID3 v2 or ID3 v1) will frequently break the file parsing logic because this code was not made robust in any way against all the variances in Mp3 and Metadata encoding in the world. There are also a few cases where the sync logic breaks. You'd have to debug with your specific media file to determine if either of these is the case.

DaveSmits wrote  Jul 15 at 1:58 PM  
is there also a manner to extend these classes to play webstreams? when i try to download a stream getting an security exception. Can't place an clientpolicy.xml because i use shoutcast and that don't serve custom files.

markkesty wrote  Sep 17 at 1:00 PM  
I'm actually working with this in Silverlight 3, placing a raw PCM 16 bit audio stream in the MediaStreamSource and it plays great!

The problem is, as mentioned by someone above, that setting the position has no effect. Also, reading the current position (for example, to move a slider or display the current position in a TextBlock) gives a position which keeps increasing but is not correct. (It looks like it increments about 1 second for every 7 seconds of play). Is this a bug? Or could I be doing something wrong?

Mark

Updating...
Page view tracker