51
rated 0 times
[
58]
[
7]
/ answers: 1 / hits: 32181
/ 12 Years ago, thu, august 30, 2012, 12:00:00
How can I use Javascript to play an HTML5 <video>
?
For example, play the video at a onclick
event.
More From » html
How can I use Javascript to play an HTML5 <video>
?
For example, play the video at a onclick
event.
Add an event listener to your play button where it calls videoElem.play()
HTML:
<video id='video'>
<source src="your-video-source.mp4" type="video/mp4">
</video>
<button id='playVid'>Play</button>
Javascript:
document.getElementById('playVid').onclick = function () {
document.getElementById('video').play();
};