Android7.0中文文档(API)--- VideoView
来源:互联网 发布:im短域名 编辑:程序博客网 时间:2024/06/06 02:11
完整内容,请查看:http://www.zhdoc.net/android/reference/android/widget/VideoView.html
VideoView
public class VideoView
extendsSurfaceView
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类可以从不同的源载入视频(如资源或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 viaaddSubtitleSource()
. Applications should save and restore these on their own in onSaveInstanceState(Bundle)
andonRestoreInstanceState(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
. UsesetAudioFocusRequest(int)
to change this behavior.
默认情况下,VideoView请求音频焦点为AUDIOFOCUS_GAIN
。调用setAudioFocusRequest(int)
来更改此行为。
The default AudioAttributes
used during playback have a usage ofUSAGE_MEDIA
and a content type ofCONTENT_TYPE_MOVIE
, usesetAudioAttributes(AudioAttributes)
to modify them.
在播放期间,默认的AudioAttributes
属性使用了USAGE_MEDIA
和CONTENT_TYPE_MOVIE
的内容类型,调用setAudioAttributes(AudioAttributes)
来修改它们。
摘要
继承XML属性
android.view.View
继承常量
android.view.View
继承字段
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.
添加一个外部字幕源文件(InputStream参数)注意,单个外部字幕源文件可能包含多个或不支持的字幕流。
boolean
canPause()
boolean
canSeekBackward()
boolean
canSeekForward()
void
draw(Canvas canvas)
Manually render this view (and all of its children) to the given Canvas.
手动将此视图 (及其所有子项) 渲染到指定的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.
获取该VideoView使用的播放器的音频会话id。
int
getBufferPercentage()
int
getCurrentPosition()
int
getDuration()
boolean
isPlaying()
boolean
onKeyDown(int keyCode,KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyDown()
: perform press of the view whenKEYCODE_DPAD_CENTER
orKEYCODE_ENTER
is released, if the view is enabled and clickable.KeyEvent.Callback.onKeyDown()
的默认实现;如果视图是使能的并且可点击,则当KEYCODE_DPAD_CENTER
或KEYCODE_ENTER
释放后,执行此视图的按键按下事件。
boolean
onTouchEvent(MotionEvent ev)
Implement this method to handle touch screen motion events.
实现此方法,以处理触摸屏的MotionEvent。
boolean
onTrackballEvent(MotionEvent ev)
Implement this method to handle trackball motion events.
实现此方法,以处理滚迹球的MotionEvent。
void
pause()
int
resolveAdjustedSize(int desiredSize, int measureSpec)
void
resume()
void
seekTo(int msec)
void
setAudioAttributes(AudioAttributes attributes)
Sets the AudioAttributes
to be used during the playback of the video.
设置AudioAttributes
,它用于视频播放期间。
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.
设置视频的URI,其使用指定的头部。
void
setVideoURI(Uri uri)
Sets video URI.
设置视频的URI。
void
start()
void
stopPlayback()
void
suspend()
保护方法
- Android7.0中文文档(API)--- VideoView
- Android7.0中文文档(API)--- FrameLayout
- Android7.0中文文档(API)--- DatePicker
- Android7.0中文文档(API) --- MediaController
- Android7.0中文文档(API)--- TabHost
- Android7.0中文文档(API) -- TimePicker
- Android7.0中文文档(API)-- ViewAnimator
- Android7.0中文文档(API)--- AbsoluteLayout
- Android7.0中文文档(API) -- Switch
- Android7.0中文文档(API) --- ToggleButton
- Android7.0中文文档(API) --- RadioButton
- Android7.0中文文档(API) --- CheckedTextView
- Android7.0中文文档(API) -- ScrollView
- Android7.0中文文档(API)-- DigitalClock
- Android7.0中文文档(API)-- TextClock
- Android7.0中文文档(API)---Chronometer
- Android7.0中文文档(API)--- AdapterView
- Android7.0中文文档(API)--- AdapterViewAnimator
- 路径压缩
- 优化iOS程序性能的25个方法
- 分点新技能+网络流
- Java与算法(5)
- 漫画说算法--动态规划算法一(绝对通俗易懂,非常棒)
- Android7.0中文文档(API)--- VideoView
- 【设计原则】面向对象编程的六大原则
- Eclipse导入其他Eclipse写的Android项目error:Activity cannot be resolved to a type
- 记一次线上centOS服务器,nginx的https配置
- strut2中文件的上传与下载
- robot framework selenium2library的一些基本操作介绍,含常见问题
- Python中的random模块
- [hdu5181]numbers
- android获取视频、图片时添加防盗链