当文件在HTML中不可用或为空时,请使用HTML中的onemptied 属性执行脚本。
您可以尝试运行以下代码来实现 onemptied 属性-
<!DOCTYPE HTML> <html> <body> <video width = "300" height = "200" controls onemptied ="display()"> <source src = "/html5/foo.ogg" type = "video/ogg" /> Your browser does not support the video element. </video> <script> function display() { alert ("Sorry! Empty playlist!"); } </script> </body> </html>