HTML DOM Video objekt

Video-objektet

Video-objektet är ett nytt objekt i HTML5.

Video-objektet representerar HTML <video>-elementet.

Åtkomst till Video-objektet

Du kan komma åt <video>-elementet genom att använda getElementById():

var x = document.getElementById("myVideo");

Try it yourself

Create Video object

You can create a <video> element by using the document.createElement() method:

var x = document.createElement("VIDEO");

Try it yourself

Video object properties

egenskaper Beskrivning
audioTracks Return the AudioTrackList object representing the available audio tracks.
autoplay Set or return whether the video should be played immediately after loading.
buffered Return the TimeRanges object representing the buffered parts of the video.
controller Return the MediaController object representing the current media controller of the video.
controls Set or return whether the video controls (such as play/pause) should be displayed.
crossOrigin Set or return the CORS settings of the video.
currentSrc Return the current URL of the 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 of the video.
duration Return the length of the video (in seconds).
ended Return whether the playback of the video has ended.
error Return the MediaError object representing the error state of the video.
height Set or return the value of the video's height attribute.
loop Set or return whether the video should play again at the end.
mediaGroup Set or return the name of the media group to which the video belongs.
muted Set or return whether the sound is turned off.
networkState Return the current network state of the video.
paused Set or return whether the video is paused.
playbackRate Set or return the playback speed of the video.
played Return the TimeRanges object representing the played parts of the video.
poster Set or return the value of the video's poster attribute.
preload Set or return the value of the video's preload attribute.
readyState Return the current ready state of the video.
seekable Return the TimeRanges object representing the addressable parts of the video.
seeking Returnera om användaren för närvarande letar i videon.
src Ställ in eller returnera värdet för videoens src-egenskap.
startDate Returnera en Date-objekt som representerar den aktuella tidsskiftet.
textTracks Returnera en TextTrackList-objekt som representerar tillgängliga text-spår.
videoTracks Returnera en VideoTrackList-objekt som representerar tillgängliga video-spår.
volume Ställ in eller returnera värdet för videoens volym.
width Ställ in eller returnera värdet för videoens width-egenskap.

Video-objektmetoder

Metod Beskrivning
addTextTrack() Lägg till en ny textspår till videon.
canPlayType() Kontrollera om webbläsaren kan spela upp det specifika videotypen.
load() Ladda om videoelementet.
play() Börja spela upp videon.
pause() Pausa den aktuella videoplayeren.

Standardegenskaper och händelser

Video-objektet stöder standarderegenskaperochHändelser.

Relaterade sidor

HTML-lärbok:HTML5-video

HTML-referenshandbok:HTML <video>-tagget