io.vov.vitamio.widget
Class VideoView
java.lang.Object
SurfaceView
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)
Constructor Summary |
VideoView(Context context)
|
VideoView(Context context,
AttributeSet attrs)
|
VideoView(Context context,
AttributeSet attrs,
int defStyle)
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
VideoView
public VideoView(Context context)
VideoView
public VideoView(Context context,
AttributeSet attrs)
VideoView
public VideoView(Context context,
AttributeSet attrs,
int defStyle)
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