public class NativeVideoDelegate
extends java.lang.Object
TextureView
and SurfaceView
implementationsModifier and Type | Class and Description |
---|---|
static interface |
NativeVideoDelegate.Callback |
class |
NativeVideoDelegate.InternalListeners |
static class |
NativeVideoDelegate.State |
Modifier and Type | Field and Description |
---|---|
protected NativeVideoDelegate.Callback |
callback |
protected ClearableSurface |
clearableSurface |
protected android.content.Context |
context |
protected int |
currentBufferPercent |
protected NativeVideoDelegate.State |
currentState |
protected java.util.Map<java.lang.String,java.lang.String> |
headers |
protected NativeVideoDelegate.InternalListeners |
internalListeners |
protected ListenerMux |
listenerMux |
protected android.media.MediaPlayer |
mediaPlayer |
protected android.media.MediaPlayer.OnBufferingUpdateListener |
onBufferingUpdateListener |
protected android.media.MediaPlayer.OnCompletionListener |
onCompletionListener |
protected android.media.MediaPlayer.OnErrorListener |
onErrorListener |
protected android.media.MediaPlayer.OnInfoListener |
onInfoListener |
protected android.media.MediaPlayer.OnPreparedListener |
onPreparedListener |
protected android.media.MediaPlayer.OnSeekCompleteListener |
onSeekCompleteListener |
protected boolean |
playRequested |
protected long |
requestedSeek |
Constructor and Description |
---|
NativeVideoDelegate(android.content.Context context,
NativeVideoDelegate.Callback callback,
ClearableSurface clearableSurface) |
Modifier and Type | Method and Description |
---|---|
int |
getBufferPercentage() |
long |
getCurrentPosition() |
long |
getDuration() |
protected void |
initMediaPlayer() |
boolean |
isPlaying() |
protected boolean |
isReady() |
void |
onSurfaceReady(android.view.Surface surface) |
void |
onSurfaceSizeChanged(int width,
int height) |
protected void |
openVideo(android.net.Uri uri) |
void |
pause() |
boolean |
restart() |
void |
seekTo(long milliseconds) |
void |
setListenerMux(ListenerMux listenerMux) |
void |
setOnBufferingUpdateListener(android.media.MediaPlayer.OnBufferingUpdateListener listener)
Register a callback to be invoked when the status of a network
stream's buffer has changed.
|
void |
setOnCompletionListener(android.media.MediaPlayer.OnCompletionListener listener)
Register a callback to be invoked when the end of a media file
has been reached during playback.
|
void |
setOnErrorListener(android.media.MediaPlayer.OnErrorListener listener)
Register a callback to be invoked when an error occurs
during playback or setup.
|
void |
setOnInfoListener(android.media.MediaPlayer.OnInfoListener listener)
Register a callback to be invoked when an informational event
occurs during playback or setup.
|
void |
setOnPreparedListener(android.media.MediaPlayer.OnPreparedListener listener)
Register a callback to be invoked when the media file
is loaded and ready to go.
|
void |
setOnSeekCompleteListener(android.media.MediaPlayer.OnSeekCompleteListener listener)
Register a callback to be invoked when a seek operation has been
completed.
|
boolean |
setPlaybackSpeed(float speed) |
void |
setVideoURI(android.net.Uri uri,
java.util.Map<java.lang.String,java.lang.String> headers)
Sets video URI using specific headers.
|
void |
start() |
void |
stopPlayback(boolean clearSurface)
Performs the functionality to stop the video in playback
|
void |
suspend()
Cleans up the resources being held.
|
protected java.util.Map<java.lang.String,java.lang.String> headers
protected NativeVideoDelegate.State currentState
protected android.content.Context context
protected NativeVideoDelegate.Callback callback
protected ClearableSurface clearableSurface
protected android.media.MediaPlayer mediaPlayer
protected boolean playRequested
protected long requestedSeek
protected int currentBufferPercent
protected ListenerMux listenerMux
@NonNull protected NativeVideoDelegate.InternalListeners internalListeners
@Nullable protected android.media.MediaPlayer.OnCompletionListener onCompletionListener
@Nullable protected android.media.MediaPlayer.OnPreparedListener onPreparedListener
@Nullable protected android.media.MediaPlayer.OnBufferingUpdateListener onBufferingUpdateListener
@Nullable protected android.media.MediaPlayer.OnSeekCompleteListener onSeekCompleteListener
@Nullable protected android.media.MediaPlayer.OnErrorListener onErrorListener
@Nullable protected android.media.MediaPlayer.OnInfoListener onInfoListener
public NativeVideoDelegate(@NonNull android.content.Context context, @NonNull NativeVideoDelegate.Callback callback, @NonNull ClearableSurface clearableSurface)
public void start()
public void pause()
public long getDuration()
public long getCurrentPosition()
public void seekTo(long milliseconds)
public boolean isPlaying()
public int getBufferPercentage()
public boolean setPlaybackSpeed(float speed)
public void stopPlayback(boolean clearSurface)
clearSurface
- true
if the surface should be clearedpublic void suspend()
public boolean restart()
public void setVideoURI(android.net.Uri uri, @Nullable java.util.Map<java.lang.String,java.lang.String> headers)
uri
- The Uri for the video to playheaders
- The headers for the URI request.
Note that the cross domain redirection is allowed by default, but that can be
changed with key/value pairs through the headers parameter with
"android-allow-cross-domain-redirect" as the key and "0" or "1" as the value
to disallow or allow cross domain redirection.public void setListenerMux(ListenerMux listenerMux)
public void setOnPreparedListener(@Nullable android.media.MediaPlayer.OnPreparedListener listener)
listener
- The callback that will be runpublic void setOnCompletionListener(@Nullable android.media.MediaPlayer.OnCompletionListener listener)
listener
- The callback that will be runpublic void setOnBufferingUpdateListener(@Nullable android.media.MediaPlayer.OnBufferingUpdateListener listener)
listener
- the callback that will be run.public void setOnSeekCompleteListener(@Nullable android.media.MediaPlayer.OnSeekCompleteListener listener)
listener
- the callback that will be runpublic void setOnErrorListener(@Nullable android.media.MediaPlayer.OnErrorListener listener)
listener
- The callback that will be runpublic void setOnInfoListener(@Nullable android.media.MediaPlayer.OnInfoListener listener)
listener
- The callback that will be runpublic void onSurfaceSizeChanged(int width, int height)
public void onSurfaceReady(android.view.Surface surface)
protected void initMediaPlayer()
protected boolean isReady()
protected void openVideo(@Nullable android.net.Uri uri)