io.vov.vitamio.widget
Class VideoView

java.lang.Object
  extended by SurfaceView
      extended by io.vov.vitamio.widget.VideoView
All Implemented Interfaces:
MediaController.MediaPlayerControl

public class VideoView
extends SurfaceView
implements MediaController.MediaPlayerControl

Displays a video file. The VideoView class can load images from various sources (such as resources or content providers), takes care of computing its measurement from the video so that it can be used in any layout manager, and provides various display options such as scaling and tinting. VideoView also provide many wrapper methods for MediaPlayer, such as getVideoWidth(), setSubShown(boolean)


Field Summary
static int VIDEO_LAYOUT_ORIGIN
           
static int VIDEO_LAYOUT_SCALE
           
static int VIDEO_LAYOUT_STRETCH
           
static int VIDEO_LAYOUT_ZOOM
           
 
Constructor Summary
VideoView(Context context)
           
VideoView(Context context, AttributeSet attrs)
           
VideoView(Context context, AttributeSet attrs, int defStyle)
           
 
Method Summary
 boolean canPause()
           
 boolean canSeekBackward()
           
 boolean canSeekForward()
           
 int getAudioTrack()
           
 java.util.HashMap<java.lang.String,java.lang.Integer> getAudioTrackMap(java.lang.String encoding)
           
 int getBufferPercentage()
           
 long getCurrentPosition()
           
 long getDuration()
           
 java.lang.String getMetaEncoding()
           
 int getSubLocation()
           
 java.lang.String getSubPath()
           
 int getSubTrack()
           
 java.util.HashMap<java.lang.String,java.lang.Integer> getSubTrackMap(java.lang.String encoding)
           
 float getVideoAspectRatio()
           
 int getVideoHeight()
           
 int getVideoWidth()
           
 boolean isBuffering()
           
 boolean isPlaying()
           
 boolean isValid()
           
 boolean onKeyDown(int keyCode, KeyEvent event)
           
 boolean onTouchEvent(MotionEvent ev)
           
 boolean onTrackballEvent(MotionEvent ev)
           
 void pause()
           
 void resume()
           
 void seekTo(long msec)
           
 void setAudioTrack(int audioIndex)
           
 void setBufferSize(int bufSize)
           
 void setMediaController(MediaController controller)
           
 void setMetaEncoding(java.lang.String encoding)
           
 void setOnBufferingUpdateListener(MediaPlayer.OnBufferingUpdateListener l)
           
 void setOnCompletionListener(MediaPlayer.OnCompletionListener l)
           
 void setOnErrorListener(MediaPlayer.OnErrorListener l)
           
 void setOnInfoListener(MediaPlayer.OnInfoListener l)
           
 void setOnPreparedListener(MediaPlayer.OnPreparedListener l)
           
 void setOnSeekCompleteListener(MediaPlayer.OnSeekCompleteListener l)
           
 void setOnSubtitleUpdateListener(MediaPlayer.OnSubtitleUpdateListener l)
           
 void setSubEncoding(java.lang.String encoding)
           
 void setSubPath(java.lang.String subPath)
           
 void setSubShown(boolean shown)
           
 void setSubTrack(int trackId)
           
 void setVideoLayout(int layout, float aspectRatio)
          Set the display options
 void setVideoPath(java.lang.String path)
           
 void setVideoQuality(int quality)
           
 void setVideoURI(Uri uri)
           
 void setVolume(float leftVolume, float rightVolume)
           
 void start()
           
 void stopPlayback()
           
 void suspend()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VIDEO_LAYOUT_ORIGIN

public static final int VIDEO_LAYOUT_ORIGIN
See Also:
Constant Field Values

VIDEO_LAYOUT_SCALE

public static final int VIDEO_LAYOUT_SCALE
See Also:
Constant Field Values

VIDEO_LAYOUT_STRETCH

public static final int VIDEO_LAYOUT_STRETCH
See Also:
Constant Field Values

VIDEO_LAYOUT_ZOOM

public static final int VIDEO_LAYOUT_ZOOM
See Also:
Constant Field Values
Constructor Detail

VideoView

public VideoView(Context context)

VideoView

public VideoView(Context context,
                 AttributeSet attrs)

VideoView

public VideoView(Context context,
                 AttributeSet attrs,
                 int defStyle)
Method Detail

setVideoLayout

public void setVideoLayout(int layout,
                           float aspectRatio)
Set the display options

Parameters:
layout -
aspectRatio - video aspect ratio, will audo detect if 0.

isValid

public boolean isValid()

setVideoPath

public void setVideoPath(java.lang.String path)

setVideoURI

public void setVideoURI(Uri uri)

stopPlayback

public void stopPlayback()

setMediaController

public void setMediaController(MediaController controller)

setOnPreparedListener

public void setOnPreparedListener(MediaPlayer.OnPreparedListener l)

setOnCompletionListener

public void setOnCompletionListener(MediaPlayer.OnCompletionListener l)

setOnErrorListener

public void setOnErrorListener(MediaPlayer.OnErrorListener l)

setOnBufferingUpdateListener

public void setOnBufferingUpdateListener(MediaPlayer.OnBufferingUpdateListener l)

setOnSeekCompleteListener

public void setOnSeekCompleteListener(MediaPlayer.OnSeekCompleteListener l)

setOnSubtitleUpdateListener

public void setOnSubtitleUpdateListener(MediaPlayer.OnSubtitleUpdateListener l)

setOnInfoListener

public void setOnInfoListener(MediaPlayer.OnInfoListener l)

onTouchEvent

public boolean onTouchEvent(MotionEvent ev)

onTrackballEvent

public boolean onTrackballEvent(MotionEvent ev)

onKeyDown

public boolean onKeyDown(int keyCode,
                         KeyEvent event)

start

public void start()
Specified by:
start in interface MediaController.MediaPlayerControl

pause

public void pause()
Specified by:
pause in interface MediaController.MediaPlayerControl

suspend

public void suspend()

resume

public void resume()

getDuration

public long getDuration()
Specified by:
getDuration in interface MediaController.MediaPlayerControl

getCurrentPosition

public long getCurrentPosition()
Specified by:
getCurrentPosition in interface MediaController.MediaPlayerControl

seekTo

public void seekTo(long msec)
Specified by:
seekTo in interface MediaController.MediaPlayerControl

isPlaying

public boolean isPlaying()
Specified by:
isPlaying in interface MediaController.MediaPlayerControl

getBufferPercentage

public int getBufferPercentage()
Specified by:
getBufferPercentage in interface MediaController.MediaPlayerControl

setVolume

public void setVolume(float leftVolume,
                      float rightVolume)

getVideoWidth

public int getVideoWidth()

getVideoHeight

public int getVideoHeight()

getVideoAspectRatio

public float getVideoAspectRatio()

setVideoQuality

public void setVideoQuality(int quality)

setBufferSize

public void setBufferSize(int bufSize)

isBuffering

public boolean isBuffering()

setMetaEncoding

public void setMetaEncoding(java.lang.String encoding)

getMetaEncoding

public java.lang.String getMetaEncoding()

getAudioTrackMap

public java.util.HashMap<java.lang.String,java.lang.Integer> getAudioTrackMap(java.lang.String encoding)

getAudioTrack

public int getAudioTrack()

setAudioTrack

public void setAudioTrack(int audioIndex)

setSubShown

public void setSubShown(boolean shown)

setSubEncoding

public void setSubEncoding(java.lang.String encoding)

getSubLocation

public int getSubLocation()

setSubPath

public void setSubPath(java.lang.String subPath)

getSubPath

public java.lang.String getSubPath()

setSubTrack

public void setSubTrack(int trackId)

getSubTrack

public int getSubTrack()

getSubTrackMap

public java.util.HashMap<java.lang.String,java.lang.Integer> getSubTrackMap(java.lang.String encoding)

canPause

public boolean canPause()
Specified by:
canPause in interface MediaController.MediaPlayerControl

canSeekBackward

public boolean canSeekBackward()
Specified by:
canSeekBackward in interface MediaController.MediaPlayerControl

canSeekForward

public boolean canSeekForward()
Specified by:
canSeekForward in interface MediaController.MediaPlayerControl