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

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 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_MEDIACONTENT_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方法

voidaddSubtitleSource(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参数)注意,单个外部字幕源文件可能包含多个或不支持的字幕流。

booleancanPause()booleancanSeekBackward()booleancanSeekForward()voiddraw(Canvas canvas)

Manually render this view (and all of its children) to the given Canvas.
手动将此视图 (及其所有子项) 渲染到指定的Canvas。

CharSequencegetAccessibilityClassName()

Return the class name of this object to be used for accessibility purposes.
返回此对象的类名,用于辅助功能目的。

intgetAudioSessionId()

Get the audio session id for the player used by this VideoView.
获取该VideoView使用的播放器的音频会话id。

intgetBufferPercentage()intgetCurrentPosition()intgetDuration()booleanisPlaying()booleanonKeyDown(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_CENTERKEYCODE_ENTER释放后,执行此视图的按键按下事件。

booleanonTouchEvent(MotionEvent ev)

Implement this method to handle touch screen motion events.
实现此方法,以处理触摸屏的MotionEvent。

booleanonTrackballEvent(MotionEvent ev)

Implement this method to handle trackball motion events.
实现此方法,以处理滚迹球的MotionEvent。

voidpause()intresolveAdjustedSize(int desiredSize, int measureSpec)voidresume()voidseekTo(int msec)voidsetAudioAttributes(AudioAttributes attributes)

Sets the AudioAttributes to be used during the playback of the video.
设置AudioAttributes,它用于视频播放期间。

voidsetAudioFocusRequest(int focusGain)

Sets which type of audio focus will be requested during the playback, or configures playback to not request audio focus.
设置在播放期间将会请求音频焦点的类型,或者配置播放,而不是请求音频焦点。

voidsetMediaController(MediaController controller) voidsetOnCompletionListener(MediaPlayer.OnCompletionListener l)

Register a callback to be invoked when the end of a media file has been reached during playback.
注册一个回调,当媒体文件播放到末尾时调用。

voidsetOnErrorListener(MediaPlayer.OnErrorListener l)

Register a callback to be invoked when an error occurs during playback or setup.
注册一个回调,当播放或设置期间发生错误时调用。

voidsetOnInfoListener(MediaPlayer.OnInfoListener l)

Register a callback to be invoked when an informational event occurs during playback or setup.
注册一个回调,当播放或设置期间发生消息事件时调用。

voidsetOnPreparedListener(MediaPlayer.OnPreparedListener l)

Register a callback to be invoked when the media file is loaded and ready to go.
注册一个回调,当媒体文件被载入并准备播放时调用。

voidsetVideoPath(String path)

Sets video path.
设置视频文件的路径。

voidsetVideoURI(Uri uri, Map<String, String> headers)

Sets video URI using specific headers.
设置视频的URI,其使用指定的头部。

voidsetVideoURI(Uri uri)

Sets video URI.
设置视频的URI。

voidstart()voidstopPlayback()voidsuspend()

保护方法

原创粉丝点击