In HTML, you can use the puase method to stop audio, and the syntax format is "object.pause();". The "pause()" method stops (pauses) the currently playing audio or video, usually used together with the "play()" method, and uses the controls attribute to display audio controls.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
pause() method stops (pauses) the currently playing audio or video.
Tips: This method is usually used with the play() method.
Tip: Use the controls attribute to display audio controls (such as audio: play, pause, seeking, volume, etc.).
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>
Effect:
The play() method starts playing the current audio.
When the mouse arrow moves into the video, the play function is triggered, and the video is developed and played;
When the mouse arrow leaves the video, the pause function is triggered, and the video is paused.
Recommended learning: html video tutorial
The above is the detailed content of How to implement audio stop in html. For more information, please follow other related articles on the PHP Chinese website!