Dela via


MediaSource Class

Definition

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 ref class MediaSource sealed : IClosable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class MediaSource final : IClosable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class MediaSource : System.IDisposable
Public NotInheritable Class MediaSource
Implements IDisposable
Inheritance
Object Platform::Object IInspectable MediaSource
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Remarks

Using one of the factory methods, you can create an instance of MediaSource from many different media source representations, including:

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.

Version history

Windows version SDK version Value added
1511 10586 CreateFromMediaBinder
1511 10586 Reset
1511 10586 State
1511 10586 StateChanged
1703 15063 AdaptiveMediaSource
1703 15063 MediaStreamSource
1703 15063 MseStreamSource
1703 15063 OpenAsync
1703 15063 Uri
1709 16299 CreateFromMediaFrameSource
1803 17134 CreateFromDownloadOperation
1803 17134 DownloadOperation

Properties

AdaptiveMediaSource

Gets the AdaptiveMediaSource associated with the MediaSource.

CustomProperties

Gets a set of properties that can be used to associate app-specific data with a MediaSource.

DownloadOperation

Retrieves the DownloadOperation with which the MediaSource is associated

Duration

Gets the duration of the content in the MediaSource.

ExternalTimedMetadataTracks

A collection of external timed metadata tracks associated with the MediaSource.

ExternalTimedTextSources

A collection of external timed text sources associated with the MediaSource.

IsOpen

Gets a value indicating whether the media source is currently open.

MediaStreamSource

Gets the MediaStreamSource associated with the MediaSource.

MseStreamSource

Gets the MseStreamSource associated with the MediaSource.

State

Gets the current state of the MediaSource.

Uri

Gets the URI associated with the MediaSource.

Methods

Close()

Closes the MediaSource.

CreateFromAdaptiveMediaSource(AdaptiveMediaSource)

Creates an instance of MediaSource from the provided AdaptiveMediaSource.

CreateFromDownloadOperation(DownloadOperation)

Creates an instance of MediaSource from the provided DownloadOperation.

CreateFromIMediaSource(IMediaSource)

Creates an instance of MediaSource from the provided IMediaSource.

CreateFromMediaBinder(MediaBinder)

Creates an instance of MediaSource from the provided MediaBinder.

CreateFromMediaFrameSource(MediaFrameSource)

Creates an instance of MediaSource from the provided AdaptiveMediaSource.

CreateFromMediaStreamSource(MediaStreamSource)

Creates an instance of MediaSource from the provided MediaStreamSource.

CreateFromMseStreamSource(MseStreamSource)

Creates an instance of MediaSource from the provided MseStreamSource.

CreateFromStorageFile(IStorageFile)

Creates an instance of MediaSource from the provided IStorageFile.

CreateFromStream(IRandomAccessStream, String)

Creates an instance of MediaSource from the provided IRandomAccessStream.

CreateFromStreamReference(IRandomAccessStreamReference, String)

Creates an instance of MediaSource from the provided IRandomAccessStreamReference.

CreateFromUri(Uri)

Creates an instance of MediaSource from the provided Uri.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

OpenAsync()

opens the backing data source for the MediaSource and reads the metadata and track information.

Reset()

Resets the internal state of the MediaSource.

Events

OpenOperationCompleted

Occurs when a MediaSource open operation completes.

StateChanged

Occurs when the current state of the MediaSource changes.

Applies to

See also