MediaSource
MediaSource
MediaSource
MediaSource
Class
Definition
Some information relates to pre-released product which may be substantially modified before it’s commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Prerelease APIs are identified by a Prerelease label.
[Contains prerelease APIs.]
Represents a media source. Provides a common way to reference media from different sources and exposes a common model for accessing media data regardless of the underlying media format.
public : sealed class MediaSource : IClosable, IMediaSource2, IMediaSource3, IMediaSource4, IMediaPlaybackSourcepublic sealed class MediaSource : IDisposable, IMediaSource2, IMediaSource3, IMediaSource4, IMediaPlaybackSourcePublic NotInheritable Class MediaSource Implements IDisposable, IMediaSource2, IMediaSource3, IMediaSource4, IMediaPlaybackSource// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Remarks
Using one of the factory methods, you can create an instance of MediaSource from many different media source representations, including:
- AdaptiveMediaSource
- MediaStreamSource
- MseStreamSource
- IStorageFile
- IRandomAccessStream
- IRandomAccessStreamReference
- Uri
After getting a MediaSource instance, create a new MediaPlaybackItem wrapping the media source and pass the MediaPlaybackItem to one of the media playback objects, such as MediaPlayer or MediaElement.
For how-to guidance for using MediaSource to play back media, see Media items, playlists, and tracks.
Properties
AdaptiveMediaSource AdaptiveMediaSource AdaptiveMediaSource AdaptiveMediaSource
Gets the AdaptiveMediaSource associated with the MediaSource.
public : AdaptiveMediaSource AdaptiveMediaSource { get; }public AdaptiveMediaSource AdaptiveMediaSource { get; }Public ReadOnly Property AdaptiveMediaSource As AdaptiveMediaSource// You can use this property in JavaScript.
The AdaptiveMediaSource associated with the MediaSource.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
Remarks
If the MediaSource does not have an associated AdaptiveMediaSource, this property value is null.
CustomProperties CustomProperties CustomProperties CustomProperties
Gets a set of properties that can be used to associate app-specific data with a MediaSource.
public : ValueSet CustomProperties { get; }public ValueSet CustomProperties { get; }Public ReadOnly Property CustomProperties As ValueSet// You can use this property in JavaScript.
A set of properties that can be used to associate app-specific data with a MediaSource.
Duration Duration Duration Duration
Gets the duration of the content in the MediaSource.
public : IReference<TimeSpan> Duration { get; }public Nullable<TimeSpan> Duration { get; }Public ReadOnly Property Duration As Nullable<TimeSpan>// You can use this property in JavaScript.
- Value
- IReference<TimeSpan> Nullable<TimeSpan> Nullable<TimeSpan> Nullable<TimeSpan>
The duration of the content in the MediaSource.
Remarks
Adaptive sources can support multiple periods or discontinuities that contribute to the overall presentation timeline. The Duration property represents this complete presentation timeline.
ExternalTimedMetadataTracks ExternalTimedMetadataTracks ExternalTimedMetadataTracks ExternalTimedMetadataTracks
A collection of external timed metadata tracks associated with the MediaSource.
public : IObservableVector<TimedMetadataTrack> ExternalTimedMetadataTracks { get; }public IObservableVector<TimedMetadataTrack> ExternalTimedMetadataTracks { get; }Public ReadOnly Property ExternalTimedMetadataTracks As IObservableVector<TimedMetadataTrack>// You can use this property in JavaScript.
- Value
- IObservableVector<TimedMetadataTrack> IObservableVector<TimedMetadataTrack> IObservableVector<TimedMetadataTrack> IObservableVector<TimedMetadataTrack>
The collection of external timed metadata tracks.
Remarks
You can generate TimedMetadataTrack objects in code and add them to this collection directly, or you can create a TimedTextSource from a URL or stream and use the ExternalTimedTextSources property to populate the collection.
ExternalTimedTextSources ExternalTimedTextSources ExternalTimedTextSources ExternalTimedTextSources
A collection of external timed text sources associated with the MediaSource.
public : IObservableVector<TimedTextSource> ExternalTimedTextSources { get; }public IObservableVector<TimedTextSource> ExternalTimedTextSources { get; }Public ReadOnly Property ExternalTimedTextSources As IObservableVector<TimedTextSource>// You can use this property in JavaScript.
- Value
- IObservableVector<TimedTextSource> IObservableVector<TimedTextSource> IObservableVector<TimedTextSource> IObservableVector<TimedTextSource>
The collection of external timed text sources.
Remarks
You can create a TimedTextSource from a URL or stream and then set this property to populate the ExternalTimedMetadataTracks collection, or you can generate TimedMetadataTrack objects in code and add them to tthe ExternalTimedMetadataTracks collection directly.
IsOpen IsOpen IsOpen IsOpen
Gets a value indicating whether the media source is currently open.
public : PlatForm::Boolean IsOpen { get; }public bool IsOpen { get; }Public ReadOnly Property IsOpen As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean bool bool bool
True if the media source is open; otherwise, false.
MediaStreamSource MediaStreamSource MediaStreamSource MediaStreamSource
Gets the MediaStreamSource associated with the MediaSource.
public : MediaStreamSource MediaStreamSource { get; }public MediaStreamSource MediaStreamSource { get; }Public ReadOnly Property MediaStreamSource As MediaStreamSource// You can use this property in JavaScript.
The MediaStreamSource associated with the MediaSource.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
Remarks
If the MediaSource does not have an associated MediaStreamSource, this property value is null.
MseStreamSource MseStreamSource MseStreamSource MseStreamSource
Gets the MseStreamSource associated with the MediaSource.
public : MseStreamSource MseStreamSource { get; }public MseStreamSource MseStreamSource { get; }Public ReadOnly Property MseStreamSource As MseStreamSource// You can use this property in JavaScript.
The MseStreamSource associated with the MediaSource.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
Remarks
If the MediaSource does not have an associated MseStreamSource, this property value is null.
State State State State
Gets the current state of the MediaSource.
public : MediaSourceState State { get; }public MediaSourceState State { get; }Public ReadOnly Property State As MediaSourceState// You can use this property in JavaScript.
The current state of the MediaSource.
| Device family |
Windows 10 (introduced v10.0.10586.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v2)
|
Uri Uri Uri Uri
Gets the URI associated with the MediaSource.
public : Uri Uri { get; }public Uri Uri { get; }Public ReadOnly Property Uri As Uri// You can use this property in JavaScript.
- Value
- Uri Uri Uri Uri
The URI associated with the MediaSource.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
Methods
Close() Close() Close() Close()
Closes the MediaSource.
public : void Close()This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.
CreateFromAdaptiveMediaSource(AdaptiveMediaSource) CreateFromAdaptiveMediaSource(AdaptiveMediaSource) CreateFromAdaptiveMediaSource(AdaptiveMediaSource) CreateFromAdaptiveMediaSource(AdaptiveMediaSource)
Creates an instance of MediaSource from the provided AdaptiveMediaSource.
public : static MediaSource CreateFromAdaptiveMediaSource(AdaptiveMediaSource mediaSource)public static MediaSource CreateFromAdaptiveMediaSource(AdaptiveMediaSource mediaSource)Public Static Function CreateFromAdaptiveMediaSource(mediaSource As AdaptiveMediaSource) As MediaSource// You can use this method in JavaScript.
The AdaptiveMediaSource from which the MediaSource is created.
The new media source.
CreateFromIMediaSource(IMediaSource) CreateFromIMediaSource(IMediaSource) CreateFromIMediaSource(IMediaSource) CreateFromIMediaSource(IMediaSource)
Creates an instance of MediaSource from the provided IMediaSource.
public : static MediaSource CreateFromIMediaSource(IMediaSource mediaSource)public static MediaSource CreateFromIMediaSource(IMediaSource mediaSource)Public Static Function CreateFromIMediaSource(mediaSource As IMediaSource) As MediaSource// You can use this method in JavaScript.
- mediaSource
- IMediaSource IMediaSource IMediaSource IMediaSource
The IMediaSource from which the MediaSource is created.
The new media source.
CreateFromMediaBinder(MediaBinder) CreateFromMediaBinder(MediaBinder) CreateFromMediaBinder(MediaBinder) CreateFromMediaBinder(MediaBinder)
Creates an instance of MediaSource from the provided MediaBinder.
public : static MediaSource CreateFromMediaBinder(MediaBinder binder)public static MediaSource CreateFromMediaBinder(MediaBinder binder)Public Static Function CreateFromMediaBinder(binder As MediaBinder) As MediaSource// You can use this method in JavaScript.
The MediaBinder with which the MediaSource is associated.
The new media source.
| Device family |
Windows 10 (introduced v10.0.10586.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v2)
|
CreateFromMediaFrameSource(MediaFrameSource) CreateFromMediaFrameSource(MediaFrameSource) CreateFromMediaFrameSource(MediaFrameSource) CreateFromMediaFrameSource(MediaFrameSource)
Prerelease. Creates an instance of MediaSource from the provided AdaptiveMediaSource.
public : static MediaSource CreateFromMediaFrameSource(MediaFrameSource frameSource)public static MediaSource CreateFromMediaFrameSource(MediaFrameSource frameSource)Public Static Function CreateFromMediaFrameSource(frameSource As MediaFrameSource) As MediaSource// You can use this method in JavaScript.
The AdaptiveMediaSource from which the MediaSource is created.
The new media source.
| Device family |
Windows 10 Insider Preview (introduced v10.0.16257.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v5)
|
Remarks
For more information on using media frame sources, see Process media frames with MediaFrameReader.
CreateFromMediaStreamSource(MediaStreamSource) CreateFromMediaStreamSource(MediaStreamSource) CreateFromMediaStreamSource(MediaStreamSource) CreateFromMediaStreamSource(MediaStreamSource)
Creates an instance of MediaSource from the provided MediaStreamSource.
public : static MediaSource CreateFromMediaStreamSource(MediaStreamSource mediaSource)public static MediaSource CreateFromMediaStreamSource(MediaStreamSource mediaSource)Public Static Function CreateFromMediaStreamSource(mediaSource As MediaStreamSource) As MediaSource// You can use this method in JavaScript.
The MediaStreamSource from which the MediaSource is created.
The new media source.
CreateFromMseStreamSource(MseStreamSource) CreateFromMseStreamSource(MseStreamSource) CreateFromMseStreamSource(MseStreamSource) CreateFromMseStreamSource(MseStreamSource)
Creates an instance of MediaSource from the provided MseStreamSource.
public : static MediaSource CreateFromMseStreamSource(MseStreamSource mediaSource)public static MediaSource CreateFromMseStreamSource(MseStreamSource mediaSource)Public Static Function CreateFromMseStreamSource(mediaSource As MseStreamSource) As MediaSource// You can use this method in JavaScript.
- mediaSource
- MseStreamSource MseStreamSource MseStreamSource MseStreamSource
The MediaStreamSource from which the MediaSource is created.
The new media source.
CreateFromStorageFile(IStorageFile) CreateFromStorageFile(IStorageFile) CreateFromStorageFile(IStorageFile) CreateFromStorageFile(IStorageFile)
Creates an instance of MediaSource from the provided IStorageFile.
public : static MediaSource CreateFromStorageFile(IStorageFile file)public static MediaSource CreateFromStorageFile(IStorageFile file)Public Static Function CreateFromStorageFile(file As IStorageFile) As MediaSource// You can use this method in JavaScript.
The IStorageFile from which the MediaSource is created.
The new media source.
CreateFromStream(IRandomAccessStream, String) CreateFromStream(IRandomAccessStream, String) CreateFromStream(IRandomAccessStream, String) CreateFromStream(IRandomAccessStream, String)
Creates an instance of MediaSource from the provided IRandomAccessStream.
public : static MediaSource CreateFromStream(IRandomAccessStream stream, PlatForm::String contentType)public static MediaSource CreateFromStream(IRandomAccessStream stream, String contentType)Public Static Function CreateFromStream(stream As IRandomAccessStream, contentType As String) As MediaSource// You can use this method in JavaScript.
The stream from which the MediaSource is created.
- contentType
- PlatForm::String String String String
The MIME type of the contents of the stream.
The new media source.
CreateFromStreamReference(IRandomAccessStreamReference, String) CreateFromStreamReference(IRandomAccessStreamReference, String) CreateFromStreamReference(IRandomAccessStreamReference, String) CreateFromStreamReference(IRandomAccessStreamReference, String)
Creates an instance of MediaSource from the provided IRandomAccessStreamReference.
public : static MediaSource CreateFromStreamReference(IRandomAccessStreamReference stream, PlatForm::String contentType)public static MediaSource CreateFromStreamReference(IRandomAccessStreamReference stream, String contentType)Public Static Function CreateFromStreamReference(stream As IRandomAccessStreamReference, contentType As String) As MediaSource// You can use this method in JavaScript.
- stream
- IRandomAccessStreamReference IRandomAccessStreamReference IRandomAccessStreamReference IRandomAccessStreamReference
The stream reference from which the MediaSource is created.
- contentType
- PlatForm::String String String String
The MIME type of the contents of the stream.
The new media source.
CreateFromUri(Uri) CreateFromUri(Uri) CreateFromUri(Uri) CreateFromUri(Uri)
Creates an instance of MediaSource from the provided Uri.
public : static MediaSource CreateFromUri(Uri uri)public static MediaSource CreateFromUri(Uri uri)Public Static Function CreateFromUri(uri As Uri) As MediaSource// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The URI from which the MediaSource is created.
The new media source.
Dispose() Dispose() Dispose() Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
This member is not implemented in C++void Dispose()Sub Disposevoid Dispose()
OpenAsync() OpenAsync() OpenAsync() OpenAsync()
opens the backing data source for the MediaSource and reads the metadata and track information.
public : IAsyncAction OpenAsync()public IAsyncAction OpenAsync()Public Function OpenAsync() As IAsyncAction// You can use this method in JavaScript.
An asynchronous action.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
Remarks
This method can be called to preload the associated media for performance reasons or to verify that the media loads successfully.
Reset() Reset() Reset() Reset()
Resets the internal state of the MediaSource.
public : void Reset()public void Reset()Public Function Reset() As void// You can use this method in JavaScript.
| Device family |
Windows 10 (introduced v10.0.10586.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v2)
|
Remarks
After Reset is called, the MediaSource will be reopened the next time it is used.
Events
OpenOperationCompleted OpenOperationCompleted OpenOperationCompleted OpenOperationCompleted
Occurs when a MediaSource open operation completes.
public : event TypedEventHandler OpenOperationCompleted<MediaSource, MediaSourceOpenOperationCompletedEventArgs>public event TypedEventHandler OpenOperationCompleted<MediaSource, MediaSourceOpenOperationCompletedEventArgs>Public Event OpenOperationCompleted<MediaSource, MediaSourceOpenOperationCompletedEventArgs>// You can use this event in JavaScript.
StateChanged StateChanged StateChanged StateChanged
Occurs when the current state of the MediaSource changes.
public : event TypedEventHandler StateChanged<MediaSource, MediaSourceStateChangedEventArgs>public event TypedEventHandler StateChanged<MediaSource, MediaSourceStateChangedEventArgs>Public Event StateChanged<MediaSource, MediaSourceStateChangedEventArgs>// You can use this event in JavaScript.
| Device family |
Windows 10 (introduced v10.0.10586.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v2)
|