Tag: Video

HTML5 Series - Video

Like Audio embedding Video in an HTML5 web page is really simple to do and has a very similar syntax.

The video tag can contain multiple source tags to specify videos in different formats as not all browsers support the same ones, and some text to be displayed if the browser does not support any. The video tag can also have a controls element specified to instruct the browser to display controls for the playback.

1<video controls>
2 <source src="URL of video.mp4" type="video/mp4">
3 <source src="URL of alternate video.ogg" type="video/ogg">
4 Your browser doesn't support viodes
5</video>

You can also set the following tags:

autoplay - Specifies that the video should begin playback immediately

loop - Sets the video to repeat

muted - Mutes the audio on playback

poster - Specifies an image to be shown what the video is downloading

preload - Specifies if an how the video should be loaded when the page loads

It is also possible to control a videos playback through JavaScript. You can reload the element, play and pause that track.

1var v = document.getElementById("myVideo");
2v.play();
3v.pause();
4v.load();