public class POBMediaPlayer extends java.lang.Object implements POBPlayer, android.media.MediaPlayer.OnPreparedListener, android.media.MediaPlayer.OnBufferingUpdateListener, android.media.MediaPlayer.OnErrorListener, android.media.MediaPlayer.OnCompletionListener, android.media.MediaPlayer.OnInfoListener, android.media.MediaPlayer.OnVideoSizeChangedListener
POBPlayer.POBPlayerListenerPROGRESS_UPDATE_DELAY| Constructor and Description |
|---|
POBMediaPlayer(java.lang.String uri,
android.os.Handler callbackHandler)
Create a new media player instance and load video in background
|
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Method to do resource cleanup
|
int |
getDuration()
Gets the duration of the media.
|
int |
getVideoHeight()
Get video player height
|
int |
getVideoWidth()
Get video player width
|
void |
onBufferingUpdate(android.media.MediaPlayer mp,
int percent)
Called to update status in buffering a media stream received through
progressive HTTP download.
|
void |
onCompletion(android.media.MediaPlayer mp)
Called when the end of a media source is reached during playback.
|
boolean |
onError(android.media.MediaPlayer mp,
int what,
int extra) |
boolean |
onInfo(android.media.MediaPlayer mp,
int what,
int extra) |
void |
onPrepared(android.media.MediaPlayer mp)
Called when the media file is ready for playback.
|
void |
onSurfaceCreated(android.view.Surface surface)
Method to notify surface created
|
void |
onSurfaceDestroyed(android.view.Surface surface)
Method to notify surface destroyed
|
void |
onVideoSizeChanged(android.media.MediaPlayer mp,
int width,
int height) |
void |
pause()
Pauses current playback.
|
void |
setPlayerListener(POBPlayer.POBPlayerListener playerListener)
Register listener to get Video Player callbacks
|
void |
setPrepareTimeout(int prepareTimeout)
Set prepare timeout to handle Player url loading.
|
void |
setStallTimeout(int stallTimeout)
Set stall timeout to handle Player buffering.
|
void |
setVolume(int leftVolume,
int rightVolume)
Set audio volume of Player
|
void |
start()
Start current playback.
|
void |
stop()
Stops playback after playback has been onStart or onPause.
|
public POBMediaPlayer(@NonNull
java.lang.String uri,
@NonNull
android.os.Handler callbackHandler)
uri - video urlcallbackHandler - handler to provide POBPlayerListener callbackspublic void setPlayerListener(@NonNull
POBPlayer.POBPlayerListener playerListener)
POBPlayersetPlayerListener in interface POBPlayerplayerListener - callback listener instancepublic void setPrepareTimeout(int prepareTimeout)
POBPlayersetPrepareTimeout in interface POBPlayerprepareTimeout - the timeout value in milliseconds.public void setStallTimeout(int stallTimeout)
POBPlayersetStallTimeout in interface POBPlayerstallTimeout - the timeout value in milliseconds.public void start()
POBPlayerpublic void pause()
POBPlayerpublic void stop()
POBPlayerpublic void setVolume(int leftVolume,
int rightVolume)
POBPlayerpublic int getDuration()
POBPlayergetDuration in interface POBPlayerpublic int getVideoWidth()
POBPlayergetVideoWidth in interface POBPlayerpublic int getVideoHeight()
POBPlayergetVideoHeight in interface POBPlayerpublic void destroy()
POBPlayerpublic void onSurfaceCreated(@NonNull
android.view.Surface surface)
POBPlayeronSurfaceCreated in interface POBPlayersurface - surface to render videopublic void onSurfaceDestroyed(@NonNull
android.view.Surface surface)
POBPlayeronSurfaceDestroyed in interface POBPlayersurface - surface to render videopublic void onVideoSizeChanged(android.media.MediaPlayer mp,
int width,
int height)
onVideoSizeChanged in interface android.media.MediaPlayer.OnVideoSizeChangedListenerpublic void onBufferingUpdate(android.media.MediaPlayer mp,
int percent)
onBufferingUpdate in interface android.media.MediaPlayer.OnBufferingUpdateListenermp - the MediaPlayer the update pertains topercent - the percentage (0-100) of the contentpublic void onCompletion(android.media.MediaPlayer mp)
onCompletion in interface android.media.MediaPlayer.OnCompletionListenermp - the MediaPlayer that reached the end of the filepublic boolean onError(android.media.MediaPlayer mp,
int what,
int extra)
onError in interface android.media.MediaPlayer.OnErrorListenerpublic boolean onInfo(android.media.MediaPlayer mp,
int what,
int extra)
onInfo in interface android.media.MediaPlayer.OnInfoListenerpublic void onPrepared(android.media.MediaPlayer mp)
onPrepared in interface android.media.MediaPlayer.OnPreparedListenermp - the MediaPlayer that is ready for playback