完整内容,请查看:http://www.zhdoc.net/android/reference/android/widget/VideoView.html
VideoView
public class VideoView
extends SurfaceView
implements MediaController.MediaPlayerControl
java.lang.Object | |||
↳ | android.view.View | ||
↳ | android.view.SurfaceView | ||
↳ | android.widget.VideoView |
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类可以从不同的源载入视频(如资源或content provider),并负责计算从视频中得到的尺寸,这样它就可以在任何布局管理器中使用,并提供各种显示选项,例如缩放和着色。
Note: VideoView does not retain its full state when going into the background. In particular, it does not restore the current play state, play position, selected tracks, or any subtitle tracks added via addSubtitleSource()
. Applications should save and restore these on their own in onSaveInstanceState(Bundle)
and onRestoreInstanceState(Bundle)
.
注意:VideoView进入后台后,并不保留它的全部状态。特别是,它不会恢复当前的播放状态,播放位置,选择的视频流,或任何通过addSubtitleSource()
添加的字幕。应用程序应该在它们自己的onSaveInstanceState(Bundle)
和onRestoreInstanceState(Bundle)
方法中保存和恢复这些状态。
Also note that the audio session id (from getAudioSessionId()
) may change from its previously returned value when the VideoView is restored.
同样,请注意音频会话id(getAudioSessionId()
)也可能在VideoView恢复时改变先前返回的值。
By default, VideoView requests audio focus with AUDIOFOCUS_GAIN
. Use setAudioFocusRequest(int)
to change this behavior.
默认情况下,VideoView请求音频焦点为AUDIOFOCUS_GAIN
。调用setAudioFocusRequest(int)
来更改此行为。
The default AudioAttributes
used during playback have a usage of USAGE_MEDIA
and a content type of CONTENT_TYPE_MOVIE
, use setAudioAttributes(AudioAttributes)
to modify them.
在播放期间,默认的AudioAttributes
属性使用了USAGE_MEDIA
和CONTENT_TYPE_MOVIE
的内容类型,调用setAudioAttributes(AudioAttributes)
来修改它们。
摘要
继承XML属性 | |
---|---|
From class android.view.View
|
继承常量 |
---|
From class android.view.View
|
继承字段 |
---|
From class android.view.View
|
Public构造方法 | |
---|---|
VideoView(Context context) | |
VideoView(Context context, AttributeSet attrs) | |
VideoView(Context context, AttributeSet attrs, int defStyleAttr) | |
VideoView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) |
Public方法 | |
---|---|
void | addSubtitleSource(InputStream is, MediaFormat format) Adds an external subtitle source file (from the provided input stream.) Note that a single external subtitle source may contain multiple or no supported tracks in it. |
boolean | canPause() |
boolean | canSeekBackward() |
boolean | canSeekForward() |
void | draw(Canvas canvas) Manually render this view (and all of its children) to the given Canvas. |
CharSequence | getAccessibilityClassName() Return the class name of this object to be used for accessibility purposes. |
int | getAudioSessionId() Get the audio session id for the player used by this VideoView. |
int | getBufferPercentage() |
int | getCurrentPosition() |
int | getDuration() |
boolean | isPlaying() |
boolean | onKeyDown(int keyCode, KeyEvent event) Default implementation of |
boolean | onTouchEvent(MotionEvent ev) Implement this method to handle touch screen motion events. |
boolean | onTrackballEvent(MotionEvent ev) Implement this method to handle trackball motion events. |
void | pause() |
int | resolveAdjustedSize(int desiredSize, int measureSpec) |
void | resume() |
void | seekTo(int msec) |
void | setAudioAttributes(AudioAttributes attributes) Sets the |
void | setAudioFocusRequest(int focusGain) Sets which type of audio focus will be requested during the playback, or configures playback to not request audio focus. |
void | setMediaController(MediaController controller) |
void | setOnCompletionListener(MediaPlayer.OnCompletionListener l) Register a callback to be invoked when the end of a media file has been reached during playback. |
void | setOnErrorListener(MediaPlayer.OnErrorListener l) Register a callback to be invoked when an error occurs during playback or setup. |
void | setOnInfoListener(MediaPlayer.OnInfoListener l) Register a callback to be invoked when an informational event occurs during playback or setup. |
void | setOnPreparedListener(MediaPlayer.OnPreparedListener l) Register a callback to be invoked when the media file is loaded and ready to go. |
void | setVideoPath(String path) Sets video path. |
void | setVideoURI(Uri uri, Map<String, String> headers) Sets video URI using specific headers. |
void | setVideoURI(Uri uri) Sets video URI. |
void | start() |
void | stopPlayback() |
void | suspend() |