C# Class Chirp.Radio.Agent.AudioPlayer

Inheritance: AudioPlayerAgent
Show file Open project: thebeekeeper/chirpradio-wp7

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.
SetCurrentTrack ( string artistName, string trackName, string album ) : void

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

this is no good! i think the json api stuff has to move in here so that it runs in the background. the front-end should be bound to the current track

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
GetNextTrack ( ) : AudioTrack

Implements the logic to get the next AudioTrack instance. In a playlist, the source can be from a file, a web request, etc.

The AudioTrack URI determines the source, which can be: (a) Isolated-storage file (Relative URI, represents path in the isolated storage) (b) HTTP URL (absolute URI) (c) MediaStreamSource (null)

GetPreviousTrack ( ) : AudioTrack

Implements the logic to get the previous AudioTrack instance.

The AudioTrack URI determines the source, which can be: (a) Isolated-storage file (Relative URI, represents path in the isolated storage) (b) HTTP URL (absolute URI) (c) MediaStreamSource (null)

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

this is no good! i think the json api stuff has to move in here so that it runs in the background. the front-end should be bound to the current track 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

SetCurrentTrack() public method

public SetCurrentTrack ( string artistName, string trackName, string album ) : void
artistName string
trackName string
album string
return void