Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

HTML DOM Video object


May 06, 2021 JavaScript with HTML DOM Reference book


Table of contents


HTML DOM Video object


Video object

Video objects are new in HTML5.

The Video object represents the HTML and video elements.

Access video object t

You can access the element by using getElementById():

var x = document.getElementById("myVideo"); Give it a try

Create a Video object

You can create an element by using the document.createElement() method:

var x = document.createElement("VIDEO"); Give it a try

Video object properties

Property Describe
audioTracks Returns the AudioTrackList object that represents the available audio tracks.
autoplay Set or return whether the video plays after it is ready (loaded finished).
buffered Returns the TimeRanges object that represents the buffered portion of the video.
controller Returns the MediaController object that represents the video's current media controller.
controls Set or return whether the video should display controls (such as play/pause, etc.).
crossOrigin Set or return corS settings for the video.
currentSrc Returns the URL of the current video.
currentTime Set or return the current playback position in the video in seconds.
defaultMuted Set or return whether the video is muted by default.
defaultPlaybackRate Set or return the default playback speed for the video.
duration Returns the length of the video in seconds.
ended Returns whether the playback of the video has ended.
error Returns the MediaError object that represents the state of the video error.
height Set or return the value of the video's height property.
loop Set or return whether the video should play again at the end.
mediaGroup Set or return the name of the media combination to which the video belongs.
muted Set or return whether to turn off the sound.
networkState Returns the current network status of the video.
paused Set or return whether the video is paused.
playbackRate Set or return the speed at which the video plays.
played Returns the TimeRanges object that indicates that the video has been played.
poster Set or return the value of the poster property for the video.
preload Set or return the value of the preload property for the video.
readyState Returns the current ready state of the video.
seekable Returns the TimeRanges object that represents the addressable portion of the video.
seeking Returns whether the user is currently looking in the video.
Src Set or return the value of the src property for the video.
startDate Returns the Date object that represents the current time offset.
textTracks Returns the TextTrackList object that represents an available text track.
videoTracks Returns the VideoTrackList object that represents the available video tracks.
volume Set or return the volume of the video.
width Set or return the value of the width property for the video.

Video object method

Method Describe
addTextTrack() Add a new text track to the video.
canPlayType() Check that the browser is able to play the specified video type.
load() Reload the video element.
play() Start playing the video.
pause() Pause the currently playing video.

Standard properties and events

Video objects also support standard properties and events.


Related articles

HTML tutorial: HTML5 video

HTML Reference Manual: HTML slt;video.gt; Tags