C# Class Plugin.MediaManager.MediaServiceBase

Inheritance: Android.App.Service, AudioManager.IOnAudioFocusChangeListener, IPlaybackManager
Mostrar archivo Open project: martijn00/XamarinMediaManager Class Usage Examples

Public Methods

Method Description
AquireWifiLock ( ) : void

Lock the wifi so we can still stream under lock screen

GetUriFromPath ( Android.Content.Context context, string path ) : string
HandleIntent ( Android.Content.Intent intent ) : void
InitializePlayer ( ) : void

Intializes the player.

InitializePlayerWithUrl ( string audioUrl ) : void
OnAudioFocusChange ( AudioFocus focusChange ) : void

For a good user experience we should account for when audio focus has changed. There is only 1 audio output there may be several media services trying to use it so we should act correctly based on this. "duck" to be quiet and when we gain go full. All applications are encouraged to follow this, but are not enforced.

OnBind ( Android.Content.Intent intent ) : IBinder
OnCreate ( ) : void

On create simply detect some of our managers

OnDestroy ( ) : void

Properly cleanup of your player by releasing resources

OnUnbind ( Android.Content.Intent intent ) : bool
Pause ( ) : System.Threading.Tasks.Task
Play ( IEnumerable mediaFiles ) : System.Threading.Tasks.Task
Play ( IMediaFile mediaFile = null ) : System.Threading.Tasks.Task
ReleaseWifiLock ( ) : void

This will release the wifi lock if it is no longer needed

Seek ( System.TimeSpan position ) : System.Threading.Tasks.Task
SetMediaPlayerDataSource ( ) : Task
SetMediaPlayerOptions ( ) : void
SetVolume ( float leftVolume, float rightVolume ) : void
Stop ( ) : System.Threading.Tasks.Task
TogglePlayPause ( bool forceToPlay ) : System.Threading.Tasks.Task

Protected Methods

Method Description
OnBufferingChanged ( BufferingChangedEventArgs e ) : void
OnMediaFailed ( MediaFailedEventArgs e ) : void
OnMediaFileChanged ( MediaFileChangedEventArgs e ) : void
OnMediaFileFailed ( MediaFileFailedEventArgs e ) : void
OnMediaFinished ( MediaFinishedEventArgs e ) : void
OnPlayingChanged ( PlayingChangedEventArgs e ) : void
OnStatusChanged ( StatusChangedEventArgs e ) : void

Private Methods

Method Description
CheckIfFileAlreadyIsPlaying ( IMediaFile mediaFile ) : Task

Checks if player just paused.

SetMediaSession ( MediaSessionManager sessionManager ) : void
ValidateMediaFile ( IMediaFile mediaFile ) : bool

Method Details

AquireWifiLock() public method

Lock the wifi so we can still stream under lock screen
public AquireWifiLock ( ) : void
return void

GetUriFromPath() public static method

public static GetUriFromPath ( Android.Content.Context context, string path ) : string
context Android.Content.Context
path string
return string

HandleIntent() public method

public HandleIntent ( Android.Content.Intent intent ) : void
intent Android.Content.Intent
return void

InitializePlayer() public abstract method

Intializes the player.
public abstract InitializePlayer ( ) : void
return void

InitializePlayerWithUrl() public abstract method

public abstract InitializePlayerWithUrl ( string audioUrl ) : void
audioUrl string
return void

OnAudioFocusChange() public method

For a good user experience we should account for when audio focus has changed. There is only 1 audio output there may be several media services trying to use it so we should act correctly based on this. "duck" to be quiet and when we gain go full. All applications are encouraged to follow this, but are not enforced.
public OnAudioFocusChange ( AudioFocus focusChange ) : void
focusChange AudioFocus
return void

OnBind() public method

public OnBind ( Android.Content.Intent intent ) : IBinder
intent Android.Content.Intent
return IBinder

OnBufferingChanged() protected method

protected OnBufferingChanged ( BufferingChangedEventArgs e ) : void
e Plugin.MediaManager.Abstractions.EventArguments.BufferingChangedEventArgs
return void

OnCreate() public method

On create simply detect some of our managers
public OnCreate ( ) : void
return void

OnDestroy() public method

Properly cleanup of your player by releasing resources
public OnDestroy ( ) : void
return void

OnMediaFailed() protected method

protected OnMediaFailed ( MediaFailedEventArgs e ) : void
e MediaFailedEventArgs
return void

OnMediaFileChanged() protected method

protected OnMediaFileChanged ( MediaFileChangedEventArgs e ) : void
e Plugin.MediaManager.Abstractions.EventArguments.MediaFileChangedEventArgs
return void

OnMediaFileFailed() protected method

protected OnMediaFileFailed ( MediaFileFailedEventArgs e ) : void
e Plugin.MediaManager.Abstractions.EventArguments.MediaFileFailedEventArgs
return void

OnMediaFinished() protected method

protected OnMediaFinished ( MediaFinishedEventArgs e ) : void
e Plugin.MediaManager.Abstractions.EventArguments.MediaFinishedEventArgs
return void

OnPlayingChanged() protected method

protected OnPlayingChanged ( PlayingChangedEventArgs e ) : void
e Plugin.MediaManager.Abstractions.EventArguments.PlayingChangedEventArgs
return void

OnStatusChanged() protected method

protected OnStatusChanged ( StatusChangedEventArgs e ) : void
e Plugin.MediaManager.Abstractions.EventArguments.StatusChangedEventArgs
return void

OnUnbind() public method

public OnUnbind ( Android.Content.Intent intent ) : bool
intent Android.Content.Intent
return bool

Pause() public method

public Pause ( ) : System.Threading.Tasks.Task
return System.Threading.Tasks.Task

Play() public abstract method

public abstract Play ( IEnumerable mediaFiles ) : System.Threading.Tasks.Task
mediaFiles IEnumerable
return System.Threading.Tasks.Task

Play() public method

public Play ( IMediaFile mediaFile = null ) : System.Threading.Tasks.Task
mediaFile IMediaFile
return System.Threading.Tasks.Task

ReleaseWifiLock() public method

This will release the wifi lock if it is no longer needed
public ReleaseWifiLock ( ) : void
return void

Seek() public abstract method

public abstract Seek ( System.TimeSpan position ) : System.Threading.Tasks.Task
position System.TimeSpan
return System.Threading.Tasks.Task

SetMediaPlayerDataSource() public abstract method

public abstract SetMediaPlayerDataSource ( ) : Task
return Task

SetMediaPlayerOptions() public abstract method

public abstract SetMediaPlayerOptions ( ) : void
return void

SetVolume() public abstract method

public abstract SetVolume ( float leftVolume, float rightVolume ) : void
leftVolume float
rightVolume float
return void

Stop() public method

public Stop ( ) : System.Threading.Tasks.Task
return System.Threading.Tasks.Task

TogglePlayPause() public abstract method

public abstract TogglePlayPause ( bool forceToPlay ) : System.Threading.Tasks.Task
forceToPlay bool
return System.Threading.Tasks.Task