How to implement audio stop in html

醉折花枝作酒筹
Release: 2021-06-08 17:02:18
Original
4570 people have browsed it

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.

How to implement audio stop in html

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>
Copy after login

Effect:

How to implement audio stop in html

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!