Windows Dev Center

MediaPlayer class

Provides access to media playback functionality such as play, pause, fast-forward, rewind, and volume.

Syntax


var mediaPlayer = current;

Attributes

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

Members

The MediaPlayer class has these types of members:

Events

The MediaPlayer class has these events.

EventDescription
BufferingEnded Occurs when buffering has finished.
BufferingStarted Occurs when buffering has started.
CurrentStateChanged Occurs when the state of the media player has changed.
MediaEnded Occurs when the media has finished playback.
MediaFailed Occurs when an error is encountered.
MediaOpened Occurs when the media is opened.
MediaPlayerRateChanged Occurs when the media playback rate has changed.
PlaybackMediaMarkerReached Occurs when a media marker has been reached during playback.
SeekCompleted Occurs when a seek operation has finished.
VolumeChanged Occurs when the volume of the audio has changed.

 

Methods

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

MethodDescription
Pause Pauses media playback.
Play Starts media playback.
SetFileSource Set the media source to a file.
SetMediaSource Sets the media source for playback.
SetStreamSource Sets the media source to a stream.
SetUriSource Sets the path to the media.

 

Properties

The MediaPlayer class has these properties.

PropertyAccess typeDescription

AutoPlay

Read/writeGets or sets a Boolean value indicating if playback automatically starts after the media is loaded.

BufferingProgress

Read-onlyGets the amount of buffering that is completed for the media content, expressed as a percentage.

CanPause

Read-onlyGets a Boolean value indicating if the media can be paused.

CanSeek

Read-onlyGets a Boolean value indicating if the media supports seeking to a specific position.

CurrentState

Read-onlyGets the current state of media playback.

IsLoopingEnabled

Read/writeGets or sets a Boolean value indicating if the media will playback in a repeating loop.

IsMuted

Read/writeGets or sets a Boolean value indicating if the audio is muted.

IsProtected

Read-onlyGets a Boolean value indicating if the content is protected by a digital rights management system.

NaturalDuration

Read-onlyGet the actual duration of the media without applying the PlaybackRate.

PlaybackMediaMarkers

Read-onlyGets the collection of timeline markers for the media.

PlaybackRate

Read/writeGets or sets the playback rate, expressed as a percentage.

Position

Read/writeGets or sets the playback position within the media.

ProtectionManager

Read/writeGets or sets the content protection manager for the media.

Volume

Read/writeGet or sets the audio volume for media playback.

 

Requirements (device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

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

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (operating system)

Minimum supported client

None supported [Windows Store apps only]

Minimum supported server

None supported [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

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

Metadata

Windows.winmd

See also

Object

 

 

Community Additions

ADD
Show:
© 2015 Microsoft