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

HTML 5 video or audio playlist

王林
王林forward
2023-08-28 09:37:02687browse

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>

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 />

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete