Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MediaStreamSource Class

Silverlight

A MediaStreamSource delivers media samples directly to the media pipeline and is most often used to enable the MediaElement to use a container format not natively supported by Silverlight.

System.Object
  System.Windows.Media.MediaStreamSource

Namespace:  System.Windows.Media
Assembly:  System.Windows (in System.Windows.dll)

public abstract class MediaStreamSource

The MediaStreamSource type exposes the following members.

  NameDescription
Protected methodSupported by Silverlight for Windows PhoneMediaStreamSourceInitializes a new instance of the MediaStreamSource class.
Top

  NameDescription
Protected propertySupported by Silverlight for Windows PhoneAudioBufferLengthGets or sets the length of the audio buffer.
Public propertyMaxDecryptorCountGets the maximum number of decryptors allowed in the decryptor buffer.
Top

  NameDescription
Protected methodBeginDrmSetupDecryptor(Byte[], Guid)Starts the process of creating a new decryptor.
Protected methodBeginDrmSetupDecryptor(Byte[], Guid, Object)Starts the process of creating a new decryptor.
Protected methodSupported by Silverlight for Windows PhoneCloseMediaThe MediaElement can call this method when going through normal shutdown or as a result of an error. This lets the developer perform any needed cleanup of the MediaStreamSource.
Public methodSupported by Silverlight for Windows PhoneEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneErrorOccurredDevelopers call this method whenever an unrecoverable error has occurred in the MediaStreamSource. This will cause the MediaFailed event to be raised.
Protected methodSupported by Silverlight for Windows PhoneFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneGetDiagnosticAsyncThe MediaElement can call this method to request information about the MediaStreamSource. Developers respond to this method by calling ReportGetDiagnosticCompleted.
Public methodSupported by Silverlight for Windows PhoneGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneGetSampleAsyncThe MediaElement calls this method to ask the MediaStreamSource to prepare the next MediaStreamSample of the requested stream type for the media pipeline. Developers can respond to this method by calling either ReportGetSampleCompleted or ReportGetSampleProgress.
Public methodSupported by Silverlight for Windows PhoneGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneOpenMediaAsyncThe MediaElement calls this method to ask the MediaStreamSource to open the media.
Protected methodSupported by Silverlight for Windows PhoneReportGetDiagnosticCompletedDevelopers call this method, in response to GetDiagnosticAsync, to pass the requested diagnostic information to the MediaElement.
Protected methodSupported by Silverlight for Windows PhoneReportGetSampleCompletedDevelopers call this method in response to GetSampleAsync to give the MediaElement the next media sample to be rendered, or to report the end of a stream.
Protected methodSupported by Silverlight for Windows PhoneReportGetSampleProgressDevelopers call this method in response to GetSampleAsync to inform the MediaElement that it will not return a sample right now, because the MediaStreamSource needs to refill its buffers, and to allow the MediaElement to transition to the Buffering state.
Protected methodSupported by Silverlight for Windows PhoneReportOpenMediaCompletedDevelopers call this method in response to OpenMediaAsync to inform the MediaElement that the MediaStreamSource has been opened and to supply information about the streams it contains.
Protected methodSupported by Silverlight for Windows PhoneReportSeekCompletedDevelopers call this method in response to SeekAsync to inform the MediaElement that the MediaStreamSource has finished the requested position change and that future calls to ReportGetSampleCompleted will return samples from that point in the media.
Protected methodSupported by Silverlight for Windows PhoneReportSwitchMediaStreamCompleted Developers call this method in response to SwitchMediaStreamAsync to inform the MediaElement that the MediaStreamSource has completed the requested stream switch and that samples returned will now be from the requested stream instead of the original stream. Note, that this is meant for the multiple audio stream case, for example language tracks, and not the adaptive streaming case.
Protected methodSupported by Silverlight for Windows PhoneSeekAsync The MediaElement calls this method to ask the MediaStreamSource to seek to the nearest randomly accessible point before the specified time. Developers respond to this method by calling ReportSeekCompleted and by ensuring future calls to ReportGetSampleCompleted will return samples from that point in the media.
Protected methodSupported by Silverlight for Windows PhoneSwitchMediaStreamAsyncCalled when a stream switch is requested on the MediaElement.
Public methodSupported by Silverlight for Windows PhoneToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Protected eventDrmSetupDecryptorCompletedOccurs when the DrmSetupDecryptorCompleted event completes, regardless if the setup succeeded or failed, if the initial call to BeginDrmSetupDecryptor did not throw an exception.
Top

MediaStreamSource is a piece of the Silverlight runtime that removes 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 have not necessarily provided thus far.

For another reason, having access to elementary streams allows developers to implement scenarios that the Silverlight runtime has not had a chance to implement yet. 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.

For more information on implementing MediaStreamSource, see Implementing MediaStream Sources.

This MediaStreamSource sample will get you started using MediaStreamSource.

Version Notes

Silverlight for Windows Phone Silverlight for Windows Phone

In Silverlight for Windows Phone, when you stream a media source that is implemented to contain both audio and video, but is missing one of the streams, playback from all streams will stop. In this case, you may need to provide mock frames for the missing stream to continue playback.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

Show:
© 2014 Microsoft