public class NativeAudioPlayer extends java.lang.Object implements AudioPlayerApi
ListenerMux and to mitigate state errors.
NOTE: The listenerMux shouldn't be null when any
method utilizing it is called, however there are some cases on
Amazon devices where they incorrectly call these methods when
setting up the MediaPlayer (when in IDLE state)
| Modifier and Type | Class and Description |
|---|---|
protected class |
NativeAudioPlayer.InternalListeners |
| Modifier and Type | Field and Description |
|---|---|
protected android.content.Context |
context |
protected int |
currentBufferPercent |
protected NativeAudioPlayer.InternalListeners |
internalListeners |
protected ListenerMux |
listenerMux |
protected android.media.MediaPlayer |
mediaPlayer |
protected long |
requestedSeek |
protected float |
volumeLeft |
protected float |
volumeRight |
| Constructor and Description |
|---|
NativeAudioPlayer(android.content.Context context) |
| Modifier and Type | Method and Description |
|---|---|
int |
getAudioSessionId() |
java.util.Map<ExoMedia.RendererType,TrackGroupArray> |
getAvailableTracks()
Retrieves a list of available tracks to select from.
|
int |
getBufferedPercent() |
long |
getCurrentPosition() |
long |
getDuration() |
float |
getPlaybackSpeed() |
int |
getSelectedTrackIndex(ExoMedia.RendererType type,
int groupIndex) |
float |
getVolumeLeft() |
float |
getVolumeRight() |
WindowInfo |
getWindowInfo() |
boolean |
isPlaying() |
void |
onMediaPrepared() |
void |
pause() |
void |
prepareAsync()
Prepares the media specified with
AudioPlayerApi.setDataSource(Uri) or
AudioPlayerApi.setDataSource(Uri, MediaSource) in an asynchronous manner |
void |
release()
Releases the resources associated with this media player
|
void |
reset() |
boolean |
restart()
Prepares the media previously specified for playback.
|
void |
seekTo(long milliseconds) |
void |
setAudioStreamType(int streamType)
Sets the audio stream type for this MediaPlayer.
|
void |
setDataSource(android.net.Uri uri) |
void |
setDataSource(android.net.Uri uri,
MediaSource mediaSource) |
void |
setDrmCallback(MediaDrmCallback drmCallback)
Sets the
MediaDrmCallback to use when handling DRM for media. |
void |
setListenerMux(ListenerMux listenerMux) |
boolean |
setPlaybackSpeed(float speed)
Sets the playback speed for this MediaPlayer.
|
void |
setRepeatMode(int repeatMode) |
void |
setTrack(ExoMedia.RendererType trackType,
int trackIndex) |
void |
setTrack(ExoMedia.RendererType type,
int groupIndex,
int trackIndex) |
void |
setVolume(float left,
float right) |
void |
setWakeMode(android.content.Context context,
int mode) |
void |
start() |
void |
stopPlayback() |
boolean |
trackSelectionAvailable() |
protected final android.content.Context context
protected final android.media.MediaPlayer mediaPlayer
protected NativeAudioPlayer.InternalListeners internalListeners
protected ListenerMux listenerMux
protected long requestedSeek
protected int currentBufferPercent
protected float volumeLeft
protected float volumeRight
public void setDataSource(android.net.Uri uri)
setDataSource in interface AudioPlayerApipublic void setDataSource(android.net.Uri uri,
MediaSource mediaSource)
setDataSource in interface AudioPlayerApipublic void setDrmCallback(MediaDrmCallback drmCallback)
AudioPlayerApiMediaDrmCallback to use when handling DRM for media.
This should be called before specifying the videos uri or path
setDrmCallback in interface AudioPlayerApidrmCallback - The callback to use when handling DRM mediapublic void prepareAsync()
AudioPlayerApiAudioPlayerApi.setDataSource(Uri) or
AudioPlayerApi.setDataSource(Uri, MediaSource) in an asynchronous mannerprepareAsync in interface AudioPlayerApipublic void reset()
reset in interface AudioPlayerApipublic float getVolumeLeft()
getVolumeLeft in interface AudioPlayerApipublic float getVolumeRight()
getVolumeRight in interface AudioPlayerApipublic void setVolume(float left,
float right)
setVolume in interface AudioPlayerApipublic void seekTo(long milliseconds)
seekTo in interface AudioPlayerApipublic boolean isPlaying()
isPlaying in interface AudioPlayerApipublic void start()
start in interface AudioPlayerApipublic void pause()
pause in interface AudioPlayerApipublic void stopPlayback()
stopPlayback in interface AudioPlayerApipublic boolean restart()
AudioPlayerApirestart in interface AudioPlayerApitrue if the media was successfully restartedpublic long getDuration()
getDuration in interface AudioPlayerApipublic long getCurrentPosition()
getCurrentPosition in interface AudioPlayerApipublic int getBufferedPercent()
getBufferedPercent in interface AudioPlayerApipublic WindowInfo getWindowInfo()
getWindowInfo in interface AudioPlayerApipublic void release()
AudioPlayerApirelease in interface AudioPlayerApipublic int getAudioSessionId()
getAudioSessionId in interface AudioPlayerApipublic boolean setPlaybackSpeed(float speed)
AudioPlayerApisetPlaybackSpeed in interface AudioPlayerApispeed - The speed to play the media back atpublic float getPlaybackSpeed()
getPlaybackSpeed in interface AudioPlayerApipublic void setAudioStreamType(int streamType)
AudioPlayerApiAudioManager
for a list of stream types. Must call this method before prepare() or
prepareAsync() in order for the target stream type to become effective
thereafter.setAudioStreamType in interface AudioPlayerApistreamType - The audio stream typeAudioManagerpublic void setWakeMode(android.content.Context context,
int mode)
setWakeMode in interface AudioPlayerApipublic boolean trackSelectionAvailable()
trackSelectionAvailable in interface AudioPlayerApipublic void setTrack(ExoMedia.RendererType trackType, int trackIndex)
setTrack in interface AudioPlayerApipublic void setTrack(ExoMedia.RendererType type, int groupIndex, int trackIndex)
setTrack in interface AudioPlayerApipublic int getSelectedTrackIndex(ExoMedia.RendererType type, int groupIndex)
getSelectedTrackIndex in interface AudioPlayerApipublic java.util.Map<ExoMedia.RendererType,TrackGroupArray> getAvailableTracks()
AudioPlayerApiAudioPlayerApi.trackSelectionAvailable()
should be called before this.getAvailableTracks in interface AudioPlayerApipublic void setListenerMux(ListenerMux listenerMux)
setListenerMux in interface AudioPlayerApipublic void onMediaPrepared()
onMediaPrepared in interface AudioPlayerApipublic void setRepeatMode(int repeatMode)
setRepeatMode in interface AudioPlayerApi