使用 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('video'); video.onended = function(){ video.src = next; } </script> <video id = "video" src = "path/of/current/video.mp4" autoplayautobuffer controls />
以上是HTML 5視訊或音訊播放列表的詳細內容。更多資訊請關注PHP中文網其他相關文章!