MSDN Archive Home
Help and FAQs
All Resource Updates
Change History (all pages)
All active develpment has moved to:
Resource Page Description
Class libraries and example Applications to jump start development with and learning about Silverlight's MediaStreamSource.
To get a quick look, download Release 22.214.171.124 and look at the source in the following two projects:
After that right click on and debug the projects:
Most recent update is 126.96.36.199
Changes in 188.8.131.52:
Added Windows Phone 7 Sample
Development of this code has been made public on
There are a number of issues both meaty and small and more ready to be filed and built. Please fork the code and do great things with it and send me pull requests.
Code releases will continue to be done on CodeGallery each time a new version of Silverlight or Silverlight based technology RTMs or when enough folks add new features to the library.
Updated Mp3MediaStreamSource to run on Windows Phone 7
Updated Mp3MediaStreamSource to not require reading the entire file into memory
Updated to support Duration
Updated to support streaming content
Special thanks to Stephen Lau for contributing much of this work.
This project grew out of 3 desires:
Provide a MediaStreamSource sample that is useful for educating developers on development with Silverlight's MediaStreamSource
Provide helper classes which make it easier to use MediaStreamSource for certain scenarios (Mp3 for now)
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.
A Silverlight class library,
, 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.
A Silverlight Test Project built for nunit,
, which provides core code coverage for the MediaParsers library.
A Sliverlight class library,
, which has arguably the simplest logic imaginable for using Mp3 file streams with a MediaStreamSource.
A Sliverlight Application demo,
Mp3MediaStreamSourceDemo and Mp3MediaStreamSourceDemoWeb
, which shows the simplest interaction between a MediaElement and a MediaStreamSource.
What is a 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 2010 Ultimate
Windows Phone 7 Tools
Who are you?
Feb 21 2012 at 4:56 PM
, version 17
Mar 24 2009 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???
Apr 6 2009 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.
Jul 15 2009 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.
Sep 17 2009 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?
Jul 21 2011 at 6:21 AM
Can the MediaStreamSource be used to manipulate the audio in a video file? Any ideas how I can go about doing this?
Sign in to add a comment
Tue Jan 18 2011 at 8:00 AM
More Tags ...
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Manage Your Profile
MSDN Flash Newsletter
© 2008 Microsoft Corporation. All rights reserved.