C# Class PodcastAudioAgent.AudioPlayer

Inheritance: AudioPlayerAgent
显示文件 Open project: kypeli/Podcatcher

Public Methods

Method Description
AudioPlayer ( ) : System AudioPlayer instances can share the same process. Static fields can be used to share state between AudioPlayer instances or to communicate with the Audio Streaming agent.

Protected Methods

Method Description
OnCancel ( ) : void

Called when the agent request is getting cancelled

Once the request is Cancelled, the agent gets 5 seconds to finish its work, by calling NotifyComplete()/Abort().

OnError ( BackgroundAudioPlayer player, AudioTrack track, Exception error, bool isFatal ) : void

Called whenever there is an error with playback, such as an AudioTrack not downloading correctly

This method is not guaranteed to be called in all cases. For example, if the background agent itself has an unhandled exception, it won't get called back to handle its own errors.

OnPlayStateChanged ( BackgroundAudioPlayer player, AudioTrack track, PlayState playState ) : void

Called when the playstate changes, except for the Error state (see OnError)

Play State changes cannot be cancelled. They are raised even if the application caused the state change itself, assuming the application has opted-in to the callback. Notable playstate events: (a) TrackEnded: invoked when the player has no current track. The agent can set the next track. (b) TrackReady: an audio track has been set and it is now ready for playack. Call NotifyComplete() only once, after the agent request has been completed, including async callbacks.

OnUserAction ( BackgroundAudioPlayer player, AudioTrack track, UserAction action, object param ) : void

Called when the user requests an action using application/system provided UI

User actions do not automatically make any changes in system state; the agent is responsible for carrying out the user actions if they are supported. Call NotifyComplete() only once, after the agent request has been completed, including async callbacks.

Private Methods

Method Description
AudioPlayer_UnhandledException ( object sender, System.Windows.ApplicationUnhandledExceptionEventArgs e ) : void
clearPrimaryTile ( ) : void
getCurrentlyPlayingTrack ( ) : PlaylistItem
getNextPlaylistTrack ( ) : AudioTrack
setCurrentlyPlayingTrack ( string episodeName ) : void
updatePlayposForCurrentEpisode ( BackgroundAudioPlayer player ) : void
updateToDBPlaylistItem ( PlaylistItem pl ) : void

Method Details

AudioPlayer() public method

AudioPlayer instances can share the same process. Static fields can be used to share state between AudioPlayer instances or to communicate with the Audio Streaming agent.
public AudioPlayer ( ) : System
return System

OnCancel() protected method

Called when the agent request is getting cancelled
Once the request is Cancelled, the agent gets 5 seconds to finish its work, by calling NotifyComplete()/Abort().
protected OnCancel ( ) : void
return void

OnError() protected method

Called whenever there is an error with playback, such as an AudioTrack not downloading correctly
This method is not guaranteed to be called in all cases. For example, if the background agent itself has an unhandled exception, it won't get called back to handle its own errors.
protected OnError ( BackgroundAudioPlayer player, AudioTrack track, Exception error, bool isFatal ) : void
player BackgroundAudioPlayer The BackgroundAudioPlayer
track AudioTrack The track that had the error
error System.Exception The error that occured
isFatal bool If true, playback cannot continue and playback of the track will stop
return void

OnPlayStateChanged() protected method

Called when the playstate changes, except for the Error state (see OnError)
Play State changes cannot be cancelled. They are raised even if the application caused the state change itself, assuming the application has opted-in to the callback. Notable playstate events: (a) TrackEnded: invoked when the player has no current track. The agent can set the next track. (b) TrackReady: an audio track has been set and it is now ready for playack. Call NotifyComplete() only once, after the agent request has been completed, including async callbacks.
protected OnPlayStateChanged ( BackgroundAudioPlayer player, AudioTrack track, PlayState playState ) : void
player BackgroundAudioPlayer The BackgroundAudioPlayer
track AudioTrack The track playing at the time the playstate changed
playState PlayState The new playstate of the player
return void

OnUserAction() protected method

Called when the user requests an action using application/system provided UI
User actions do not automatically make any changes in system state; the agent is responsible for carrying out the user actions if they are supported. Call NotifyComplete() only once, after the agent request has been completed, including async callbacks.
protected OnUserAction ( BackgroundAudioPlayer player, AudioTrack track, UserAction action, object param ) : void
player BackgroundAudioPlayer The BackgroundAudioPlayer
track AudioTrack The track playing at the time of the user action
action UserAction The action the user has requested
param object The data associated with the requested action. /// In the current version this parameter is only for use with the Seek action, /// to indicate the requested position of an audio track
return void