html5 video method to stop playing a video: first use "document.getElementById("id value")" to obtain the video object; then use the "video object.pause()" statement to stop (pause) the currently playing video Just video.
The operating environment of this tutorial: windows7 system, HTML5&&javascript version 1.8.5, Dell G3 computer.
html5 videoStop playing video
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <div style="text-align:center"> <button onclick="playPause()">播放/暂停</button> <br><br> <video id="video1" width="420"> <source src="mov_bbb.mp4" type="video/mp4"> <source src="mov_bbb.ogg" type="video/ogg"> 您的浏览器不支持 HTML5 video 标签。 </video> </div> <script> var myVideo=document.getElementById("video1"); function playPause() { if (myVideo.paused) myVideo.play(); else myVideo.pause(); } </script> </body> </html>
Rendering:
Related function description:
play() method starts playing the current audio or video.
pause() method stops (pauses) the currently playing audio or video.
For more programming related knowledge, please visit: Programming Video! !
The above is the detailed content of How to stop playing video in html5 video. For more information, please follow other related articles on the PHP Chinese website!