How To Play Video In HTML5?
Before HTML5 we were using the flash player to run video files but now it is possible through HTML5.
HTML5 features, include audio and video support without the need for Flash.
The HTML5 <video> tag gives us the power to play video without any flash and other media files. For that, we will have to add an HTML5 tag on our website or wherever you want to place it. It is very simple and users can get a smooth experience of video. So today I am explaining to you, How To Play Video In HTML5
Below is the code of the HTML5 video tag. Attributes like height and width can be changed as per your need.
<video controls="controls" width="600" height="200"> <source src="sample_movie.mp4" type="video/mp4" /> <source src="sample_movie.ogg" type="video/ogg" /> Your browser does not support the video tag.</video>
Supporting Browsers
Browser | mp4 | webM | ogg |
---|---|---|---|
Internet Explorer | yes | no | no |
Google Chrome | yes | yes | yes |
Mozilla Firefox | yes | yes | yes |
Opera | no | yes | yes |
Apple Safari | yes | no | no |
Video Tag Attributes
Attribute | Description |
---|---|
autoplay | Video will be played automatically when it is ready. |
controls | It defines the video controls which is displayed with play/pause buttons. |
poster | It specifies the image which is displayed on the screen when the video is not played. |
loop | It specifies that the video file will start over again, every time when it is completed. |
src | Source URL of the video file. |
muted | We can mute the video through muted command. |
height | We can set the height of the video player. |
width | We can set the width of the video player. |