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

Applies to Windows and Windows Phone

Represents a media source that delivers media samples directly to the media pipeline.

Syntax


public sealed class MediaStreamSource : IMediaSource

Attributes

[DualApiPartition()]
[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06030000)]

Members

The MediaStreamSource class has these types of members:

Constructors

The MediaStreamSource class has these constructors.

ConstructorDescription
MediaStreamSource(IMediaStreamDescriptor) Creates an instance of MediaStreamSource from the specified IMediaStreamDescriptor.
MediaStreamSource(IMediaStreamDescriptor, IMediaStreamDescriptor) Creates an instance of MediaStreamSource from two IMediaStreamDescriptor objects.

 

Events

The MediaStreamSource class has these events.

EventDescription
Closed Occurs when the MediaStreamSource is shutting down.
Paused Occurs when the MediaStreamSource is paused and stops requesting MediaStreamSample objects for an unspecified period of time, but is expected to resume requesting MediaStreamSample objects from the current position.
SampleRequested Occurs when the MediaStreamSource request a MediaStreamSample for a specified stream.
Starting Occurs when the MediaStreamSource is ready to start requesting MediaStreamSample objects. The event can specify a position in the media time-line from which the first MediaStreamSample should be delivered.
SwitchStreamsRequested Occurs when the MediaStreamSource will stop requesting MediaStreamSample objects for a certain stream and will start requesting MediaStreamSample objects from a different stream instead.

 

Methods

The MediaStreamSource class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
AddProtectionKey Adds a Digital Rights Management (DRM) protection key which is used by the MediaProtectionManager to encrypt and decrypt the specified stream.
AddStreamDescriptor Adds a new stream descriptor to the MediaStreamSource.
NotifyError Notifies the MediaStreamSource that an error has occurred which is preventing the application from continuing to deliver data to the MediaStreamSource.
SetBufferedRange Sets the range of data that the application is currently buffering.

 

Properties

The MediaStreamSource class has these properties.

PropertyAccess typeDescription

BufferTime

Read/writeGets or sets the amount of data that is buffered by the MediaStreamSource.

CanSeek

Read/writeGets or sets whether or not the application supports changing its position in the media time-line.

Duration

Read/writeGets or sets the duration of the media time-line.

MediaProtectionManager

Read/writeGets or sets the Digital Rights Management (DRM)MediaProtectionManager used to protect the media.

MusicProperties

Read-onlyGets the music properties which are used for musicrelated metadata.

Thumbnail

Read/writeGets or sets the thumbnail which is a reference to a stream for a video thumbnail image or music album art.

VideoProperties

Read-onlyGets the video properties which are used for video related metadata.

 

Remarks

See the MediaStreamSource Sample for an example of using Media Stream Source in a Windows Store app.

MediaStreamSource is a new generic media source for Windows Store apps which is introduced in Windows 8.1. MediaStreamSource allows apps to send compressed or uncompressed audio and video samples to the media pipeline for playback, transcoding, and streaming. Media samples can be dynamically generated by the app, or de-multiplexed from a stream or files. This flexibility enables apps to more easily extend platform support for new media formats or solve complex problems, such as adaptive streaming.

The MediaStreamSource API are very similar to the Microsoft Silverlight API of the same name.

MediaStreamSource can be used with audio and video objects in Windows Store apps using JavaScript, MediaElement objects in Windows Store app using C++, C#, or Visual Basic, and the MediaTranscoder.

The MediaStreamSource Sample demonstrates how to use the MediaStreamSource.

Here are some of the main MediaStreamSource API. The order outlines the basic flow of how MediaStreamSource functions. You'll notice that the MediaStreamSource sends request objects to the app through event arguments. These request objects enable the app to interact with the MediaStreamSource and pass data back to it.

API Description
MediaStreamSourceRepresents a media source that delivers media samples directly to the media pipeline. MediaStreamSource consumes MediaStreamSample objects that are provided by the application.
MediaStreamSample Represents a media sample used by the MediaStreamSource.
MediaStreamSource.Starting (event)

The MediaStreamSource uses this event to notify the app that it is ready to start processing media data.

MediaStreamSourceStartingRequest

Represents a request from the MediaStreamSource that it is ready to start processing media data.

Apps should reply as soon as possible to this request by calling SetActualStartPosition on the request. If an app needs to delay the MediaStreamSource from processing data, it can get an asynchronous deferral from MediaStreamSourceStartingRequest.GetDeferral. When the app is ready for the MediaStreamSource to start, it calls Complete on the deferral object.

The starting request is accessed through the MediaStreamSourceStartingEventArgs that are passed to the MediaStreamSource.Starting event handler.

MediaStreamSource.SampleRequested (event)

The MediaStreamSource uses this event to notify the app that it is ready for a MediaStreamSample.

Apps are required to register a handler for this event.

MediaStreamSourceSampleRequest

Represents a request from the MediaStreamSource for a new media sample. Setting the Sample property to the new MediaStreamSample triggers the MediaStreamSource to retrieve the media sample and continue processing the media data.

Apps should reply as soon as possible to this request. If an app needs time before sending the MediaStreamSample, it can get an asynchronous deferral from MediaStreamSourceSampleRequest.GetDeferral. When the app is finished with the deferral, it calls Complete on the deferral object.

The sample request is accessed through the MediaStreamSourceSampleRequestedEventArgs that are passed to the MediaStreamSource.SampleRequest event handler.

The app indicates it has reached the end of the stream by responding to a MediaStreamSourceSampleRequest without providing a MediaStreamSample, or by assigning the MediaStreamSourceSampleRequest.Sample property to null.

MediaStreamSource.Closed (event)

The MediaStreamSource uses this event to notify the app that it has shut down.

MediaStreamSourceClosedRequest

Represents a request from the MediaStreamSource that it has closed.

The close request is accessed through the MediaStreamSourceClosedEventArgs that are passed to the MediaStreamSource.Closed event handler.

MediaElement.SetMediaStreamSource Sets the source of the MediaElement to a MediaStreamSource.

 

Requirements

Minimum supported client

Windows 8.1 [Windows Store apps, desktop apps]

Minimum supported server

Windows Server 2012 R2 [Windows Store apps, desktop apps]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.Media.Core
Windows::Media::Core [C++]

Metadata

Windows.winmd

See also

Object
IMediaSource
MediaStreamSource Sample

 

 

Show:
© 2014 Microsoft