Added in API level 1

VideoView


open class VideoView : SurfaceView, MediaController.MediaPlayerControl
kotlin.Any
   ↳ 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.

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 android.app.Activity#onSaveInstanceState and android.app.Activity#onRestoreInstanceState.

Also note that the audio session id (from getAudioSessionId) may change from its previously returned value when the VideoView is restored.

By default, VideoView requests audio focus with AudioManager.AUDIOFOCUS_GAIN. Use setAudioFocusRequest(int) to change this behavior.

The default AudioAttributes used during playback have a usage of AudioAttributes.USAGE_MEDIA and a content type of AudioAttributes.CONTENT_TYPE_MOVIE, use setAudioAttributes(AudioAttributes) to modify them.

Summary

Inherited XML attributes
Inherited constants
Public constructors
VideoView(context: Context!)

VideoView(context: Context!, attrs: AttributeSet!)

VideoView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

VideoView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Public methods
open Unit

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.

open Boolean

open Boolean

open Boolean

open Unit
draw(canvas: Canvas)

Manually render this view (and all of its children) to the given Canvas.

open CharSequence!

Return the class name of this object to be used for accessibility purposes.

open Int

Get the audio session id for the player used by this VideoView.

open Int

open Int

open Int

open Boolean

open Boolean
onKeyDown(keyCode: Int, event: KeyEvent!)

Default implementation of KeyEvent.Callback.onKeyDown(): perform press of the view when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER is released, if the view is enabled and clickable.

open Boolean

Implement this method to handle pointer events.

open Boolean

Implement this method to handle trackball motion events.

open Unit

open Int
resolveAdjustedSize(desiredSize: Int, measureSpec: Int)

open Unit

open Unit
seekTo(msec: Int)

open Unit

Sets the AudioAttributes to be used during the playback of the video.

open Unit

Sets which type of audio focus will be requested during the playback, or configures playback to not request audio focus.

open Unit

open Unit

Register a callback to be invoked when the end of a media file has been reached during playback.

open Unit

Register a callback to be invoked when an error occurs during playback or setup.

open Unit

Register a callback to be invoked when an informational event occurs during playback or setup.

open Unit

Register a callback to be invoked when the media file is loaded and ready to go.

open Unit

Sets video path.

open Unit

Sets video URI.

open Unit
setVideoURI(uri: Uri!, headers: MutableMap<String!, String!>!)

Sets video URI using specific headers.

open Unit

open Unit

open Unit

Protected methods
open Unit

This is called when the view is attached to a window.

open Unit

This is called when the view is detached from a window.

open Unit
onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int)

Called from layout when this view should assign a size and position to each of its children.

open Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

Measure the view and its content to determine the measured width and the measured height.

Inherited functions