BackgroundAudioPlayer Class

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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

Inheritance Hierarchy

System..::.Object
  Microsoft.Phone.BackgroundAudio..::.BackgroundAudioPlayer

Namespace:  Microsoft.Phone.BackgroundAudio
Assembly:  Microsoft.Phone (in Microsoft.Phone.dll)

Syntax

Public NotInheritable Class BackgroundAudioPlayer
public sealed class BackgroundAudioPlayer

The BackgroundAudioPlayer type exposes the following members.

Properties

  Name Description
BufferingProgress The amount of buffering that is completed for the media content.
CanPause Gets a value indicating whether the media can be paused when the Pause()()() method is called.
CanSeek Gets a value indicating whether the media can be repositioned by setting the value of the Position property.
Error The last error, if any, to have occurred while playing the current AudioTrack.
Instance Returns an instance of the BackgroundAudioPlayer. If this application already has background audio playback resources allocated, the BackgroundAudioPlayer returned will contain references to those resources.
PlayerState Gets the current PlayState of the player.
Position Gets or sets the current position within the current Track.
Track Gets or sets the current track for this application, whether the application is currently playing or not.
Volume The media's volume represented on a linear scale between 0 and 1. The default is 0.85.

Top

Methods

  Name Description
Close Closes the player and removes all resources reserved for it, including the current AudioTrack.
Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
FastForward Starts fast-forwarding through the current AudioTrack.
Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
GetType Gets the Type of the current instance. (Inherited from Object.)
MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Pause Pauses playback at the current position.
Play Plays or resumes the current AudioTrack at its current position.
Rewind Starts rewinding through the current AudioTrack.
SkipNext Skips to the next track.
SkipPrevious Skips to the previous track.
Stop Stops and resets media to be played from the beginning.
ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Events

  Name Description
PlayStateChanged Occurs when the PlayState changes.

Top

Remarks

This is the main class for performing playback options and registering for PlayStateChanged events independent of which playlist is currently playing. It is used by both the foreground application and the background agent. Rather than relying on events, the background agent relies on callbacks.

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1

Platforms

Windows Phone

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.Phone.BackgroundAudio Namespace

Other Resources

Background audio overview for Windows Phone 8

How to play background audio for Windows Phone 8