public class NativeVideoDelegate
extends java.lang.Object
TextureView
and SurfaceView implementations| Modifier 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 |
protected float |
requestedVolume |
| 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() |
float |
getPlaybackSpeed() |
float |
getVolume() |
WindowInfo |
getWindowInfo() |
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.
|
boolean |
setVolume(float volume) |
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 float requestedVolume
protected ListenerMux listenerMux
protected NativeVideoDelegate.InternalListeners internalListeners
protected android.media.MediaPlayer.OnCompletionListener onCompletionListener
protected android.media.MediaPlayer.OnPreparedListener onPreparedListener
protected android.media.MediaPlayer.OnBufferingUpdateListener onBufferingUpdateListener
protected android.media.MediaPlayer.OnSeekCompleteListener onSeekCompleteListener
protected android.media.MediaPlayer.OnErrorListener onErrorListener
protected android.media.MediaPlayer.OnInfoListener onInfoListener
public NativeVideoDelegate(android.content.Context context,
NativeVideoDelegate.Callback callback,
ClearableSurface clearableSurface)
public void start()
public void pause()
public long getDuration()
public long getCurrentPosition()
public float getVolume()
public boolean setVolume(float volume)
public void seekTo(long milliseconds)
public boolean isPlaying()
public int getBufferPercentage()
public WindowInfo getWindowInfo()
public boolean setPlaybackSpeed(float speed)
public float getPlaybackSpeed()
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,
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(android.media.MediaPlayer.OnPreparedListener listener)
listener - The callback that will be runpublic void setOnCompletionListener(android.media.MediaPlayer.OnCompletionListener listener)
listener - The callback that will be runpublic void setOnBufferingUpdateListener(android.media.MediaPlayer.OnBufferingUpdateListener listener)
listener - the callback that will be run.public void setOnSeekCompleteListener(android.media.MediaPlayer.OnSeekCompleteListener listener)
listener - the callback that will be runpublic void setOnErrorListener(android.media.MediaPlayer.OnErrorListener listener)
listener - The callback that will be runpublic void setOnInfoListener(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(android.net.Uri uri)