Class POBMediaPlayer
-
- All Implemented Interfaces:
-
android.media.MediaPlayer.OnBufferingUpdateListener,android.media.MediaPlayer.OnCompletionListener,android.media.MediaPlayer.OnErrorListener,android.media.MediaPlayer.OnInfoListener,android.media.MediaPlayer.OnPreparedListener,android.media.MediaPlayer.OnVideoSizeChangedListener,com.pubmatic.sdk.video.player.POBPlayer
public class POBMediaPlayer implements POBPlayer, MediaPlayer.OnPreparedListener, MediaPlayer.OnBufferingUpdateListener, MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener, MediaPlayer.OnInfoListener, MediaPlayer.OnVideoSizeChangedListener
Class responsible for native media player handling and provides basic video player functionality to play video content
-
-
Field Summary
Fields Modifier and Type Field Description public intvideoWidthpublic intvideoHeightpublic final static doublePROGRESS_UPDATE_DELAYpublic final static intMEDIA_DISPLAY_ERRORpublic final static intMEDIA_FILE_TIMEOUT_ERROR
-
Constructor Summary
Constructors Constructor Description POBMediaPlayer(String uri, Handler callbackHandler)Create a new media player instance and load video in background
-
Method Summary
Modifier and Type Method Description intgetVideoWidth()Get video player width intgetVideoHeight()Get video player height voidstart()Start current playback. voidpause()Pauses current playback. voidstop()Stops playback after playback has been onStart or onPause. voidsetVolume(int leftVolume, int rightVolume)Set audio volume of Player intgetDuration()Gets the duration of the media. voiddestroy()Method to do resource cleanup voidonSurfaceCreated(@NonNull() Surface surface)Method to notify surface created voidonSurfaceDestroyed(@NonNull() Surface surface)Method to notify surface destroyed voidonVideoSizeChanged(MediaPlayer mp, int width, int height)voidonBufferingUpdate(MediaPlayer mp, int percent)Called to update status in buffering a media stream received through progressive HTTP download. voidonCompletion(MediaPlayer mp)Called when the end of a media source is reached during playback. booleanonError(MediaPlayer mp, int what, int extra)booleanonInfo(MediaPlayer mp, int what, int extra)voidonPrepared(MediaPlayer mp)Called when the media file is ready for playback. voidsetPlayerListener(@NonNull() POBPlayer.POBPlayerListener playerListener)voidsetPrepareTimeout(int prepareTimeout)Set prepare timeout to handle Player url loading. voidsetStallTimeout(int stallTimeout)Set stall timeout to handle Player buffering. -
-
Constructor Detail
-
POBMediaPlayer
POBMediaPlayer(String uri, Handler callbackHandler)
Create a new media player instance and load video in background- Parameters:
uri- video urlcallbackHandler- handler to provide POBPlayerListener callbacks
-
-
Method Detail
-
getVideoWidth
int getVideoWidth()
Get video player width
- Returns:
video player width
-
getVideoHeight
int getVideoHeight()
Get video player height
- Returns:
video player height
-
start
void start()
Start current playback.
-
pause
void pause()
Pauses current playback.
-
stop
void stop()
Stops playback after playback has been onStart or onPause.
-
setVolume
void setVolume(int leftVolume, int rightVolume)
Set audio volume of Player
- Parameters:
leftVolume- left volumerightVolume- right volume
-
getDuration
int getDuration()
Gets the duration of the media.
- Returns:
the duration in milliseconds, if no duration is available (for example, if streaming live content), -1 is returned.
-
destroy
void destroy()
Method to do resource cleanup
-
onSurfaceCreated
void onSurfaceCreated(@NonNull() Surface surface)
Method to notify surface created
- Parameters:
surface- surface to render video
-
onSurfaceDestroyed
void onSurfaceDestroyed(@NonNull() Surface surface)
Method to notify surface destroyed
- Parameters:
surface- surface to render video
-
onVideoSizeChanged
void onVideoSizeChanged(MediaPlayer mp, int width, int height)
-
onBufferingUpdate
void onBufferingUpdate(MediaPlayer mp, int percent)
Called to update status in buffering a media stream received through progressive HTTP download. The received buffering percentage indicates how much of the content has been buffered or played. For example a buffering update of 80 percent when half the content has already been played indicates that the next 30 percent of the content to play has been buffered.
- Parameters:
mp- the MediaPlayer the update pertains topercent- the percentage (0-100) of the content
-
onCompletion
void onCompletion(MediaPlayer mp)
Called when the end of a media source is reached during playback.
- Parameters:
mp- the MediaPlayer that reached the end of the file
-
onError
boolean onError(MediaPlayer mp, int what, int extra)
-
onInfo
boolean onInfo(MediaPlayer mp, int what, int extra)
-
onPrepared
void onPrepared(MediaPlayer mp)
Called when the media file is ready for playback.
- Parameters:
mp- the MediaPlayer that is ready for playback
-
setPlayerListener
void setPlayerListener(@NonNull() POBPlayer.POBPlayerListener playerListener)
- Parameters:
playerListener- callback listener instance
-
setPrepareTimeout
void setPrepareTimeout(int prepareTimeout)
Set prepare timeout to handle Player url loading.
-
setStallTimeout
void setStallTimeout(int stallTimeout)
Set stall timeout to handle Player buffering.
- Parameters:
stallTimeout- the timeout value in milliseconds.
-
-
-
-