Use the onemptied attribute in HTML to execute a script when the file is unavailable in HTML or it is empty.
Example
You can try to run the following code to implement the onemptied attribute −
<!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>