Home > Web Front-end > HTML Tutorial > HTML 5 video or audio playlist

HTML 5 video or audio playlist

王林
Release: 2023-08-28 09:37:02
forward
781 people have browsed it

HTML 5视频或音频播放列表

Add playlists using HTML and JavaScript. When the audio/video ends, the onending event is triggered. You can add messages such as "Thank you for watching", "Stay tuned!"

Example

You can try running the following code to achieveonend Properties-

<!DOCTYPE HTML>
<html>
   <body>
      <video width = "300" height = "200" controls onended = "display()">
         <source src = "/html5/foo.ogg" type = "video/ogg" />
         Your browser does not support the video element.
      </video>
      <script>
         function display() {
            alert ("Thank you for watching! Stay tuned!");
         }
      </script>
   </body>
</html>
Copy after login

You can load the next clip in the onending event as shown in the code given below

<script >
   var next = "path/of/next/video.mp4";
   var video = document.getElementById(&#39;video&#39;);
   video.onended = function(){
   video.src = next;
}
</script>
<video id = "video" src = "path/of/current/video.mp4" autoplayautobuffer controls />
Copy after login

The above is the detailed content of HTML 5 video or audio playlist. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
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