PHP前端开发

HTML 5视频或音频播放列表

百变鹏仔 3个月前 (09-22) #HTML
文章标签 播放列表

使用 HTML 和 JavaScript 添加播放列表。当音频/视频结束时,onending事件会触发。您可以添加“感谢您观看”、“敬请关注!”等消息

示例

您可以尝试运行以下代码来实现onend 属性 -

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

您可以在onending 事件中加载下一个剪辑,如下面给出的代码所示

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