The HTML5 provides <video> element that specifies a standard way to play video in a web page.So we can play video without using any third party software like flash .
In this post we discuss about controls of the play video.
We can use some controls like play / pause video,play video in big / small screen.
<!DOCTYPE html>
<html>
<title>HTML 5 Video Player</title>
<body>
<div style="text-align:center">
<button onclick="playPauseVideo()">Play/Pause</button>
<button onclick="makeBigScreen()">Big</button>
<button onclick="makeSmallScreen()">Small</button>
<button onclick="makeNormalScreen()">Normal</button>
<br>
<video id="myVideo" width="420">
<source src="media/omg.mp4" type="video/mp4">
<source src="mov_bbb.ogg" type="video/ogg">
Your browser does not support HTML5 video.
</video>
</div>
<script>
var myVideo=document.getElementById("myVideo");
function playPauseVideo()
{
if (myVideo.paused)
myVideo.play();
else
myVideo.pause();
}
function makeBigScreen()
{
myVideo.width=960;
}
function makeSmallScreen()
{
myVideo.width=320;
}
function makeNormalScreen()
{
myVideo.width=420;
}
</script>
</body>
</html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
<!DOCTYPE html> <html> <title>HTML 5 Video Player</title> <body> <div style="text-align:center"> <button onclick="playPauseVideo()">Play/Pause</button> <button onclick="makeBigScreen()">Big</button> <button onclick="makeSmallScreen()">Small</button> <button onclick="makeNormalScreen()">Normal</button> <br> <video id="myVideo" width="420"> <source src="media/omg.mp4" type="video/mp4"> <source src="mov_bbb.ogg" type="video/ogg"> Your browser does not support HTML5 video. </video> </div> <script> var myVideo=document.getElementById("myVideo"); function playPauseVideo() { if (myVideo.paused) myVideo.play(); else myVideo.pause(); } function makeBigScreen() { myVideo.width=960; } function makeSmallScreen() { myVideo.width=320; } function makeNormalScreen() { myVideo.width=420; } </script> </body> </html> |
Demo : HTML5 Video Player