February 14, 2014
Called when the play state changes, except for the error state.
Assembly: Microsoft.Phone (in Microsoft.Phone.dll)
protected virtual void OnPlayStateChanged( BackgroundAudioPlayer player, AudioTrack track, PlayState playState )
- Type: Microsoft.Phone.BackgroundAudio.AudioTrack
The track playing at the time that the play state changed.
- Type: Microsoft.Phone.BackgroundAudio.PlayState
The new state of the player.
For changes in the error state, see OnError(BackgroundAudioPlayer, AudioTrack, Exception, Boolean).
Notifications of changes to the play state occur after the fact. They cannot be cancelled. They are raised even if the application caused the state change itself, assuming the application has opted-in to the callback.
When the Shutdown state occurs, your AudioPlayerAgent has two seconds to clean up its resources. This timer is not suppressed during debug sessions. This means that setting a breakpoint, or stepping through the code, after receiving notification of the Shutdown state may lead to unexpected behavior. The background audio service releases all resources two seconds after Shutdown is triggered.
If you don’t override the method, then it simply calls NotifyComplete().