Example
A video with play and pause buttons:
var myVideo=document.getElementById("video1"); function playVid() { myVideo.play(); } function pauseVid() { myVideo.pause(); }
Definition and usage
play() method starts playing the current audioor video.
Browser support
All major browsers support the play() method.
Note: Internet Explorer 8 and earlier versions do not support this method.
Grammar
audio|video.play()
Code example:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>视频播放</title> </head> <body> <script> window.onload =function(){ var ov=document.getElementById("a1"); ov.onmouseover=function() { this.play(); } ov.onmouseout =function() { this.pause(); } }; </script> <video id="a1" src="陈奕迅 - 陪你度过漫长岁月.mp4" controls loop width="400" height="400">你的浏览器不支持</video> </body> </html>
The above is the detailed content of How to start playing the current audio or video in html5. For more information, please follow other related articles on the PHP Chinese website!