Windows apps
Collapse the table of content
Expand the table of content
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.

MediaPlayer Class

Provides methods and properties to play, pause, resume, and stop songs. MediaPlayer also exposes shuffle, repeat, volume, play position, and visualization capabilities.

public static class MediaPlayer

MediaPlayer provides methods and properties for playing songs in the media library.

To control song playback, use the Play, Pause, Stop, and Resume methods. The MoveNext and MovePrevious methods move to the next or previous song in the queue. They operate as if the queue was circular. That is, MoveNext, when the last song is playing, moves to the first song. MovePrevious, when the first song is playing, moves to the last song.

To get and set playback options, use the IsMuted, IsRepeating, IsShuffled, PlayPosition, and Volume properties.

To obtain visualization data for the currently playing song, call GetVisualizationData.

MediaPlayer is a static class, so you do not have to use new to instantiate an instance of the class. Instead, call methods and properties directly on the class.

Capabilities for Windows Phone

If you use this API in your Windows Phone app, you must specify the following capabilities in the app manifest. Otherwise, your app might not work correctly or it might exit unexpectedly.

ID_CAP_MEDIALIBWindows Phone OS 7.1

For more info, see App capabilities and hardware requirements for Windows Phone.

Namespace: Microsoft.Xna.Framework.Media
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

Windows Phone

Community Additions

© 2018 Microsoft