English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The error attribute is the latest MediaError object; if there is no error, it is null. When the project receives the error event, it can determine the details of what happened when checking this object.
HTML Audio/Video DOM Reference Manual
Get the video error status:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Audio/video error attribute usage-Basic Tutorial(oldtoolbag.com)</<title> </<head> <body> <button onclick="getError()" type="button">Get the video error status</button> <br> <video id="video"1" controls="controls" autoplay="autoplay"> <source src="movie_no_exist.mp"4" type="video"/mp4"> <source src="movie_no_exist.ogg" type="video"/ogg"> Your browser does not support HTML5 video tag. </video> <script> myVid=document.getElementById("video"1); function getError() { alert(myVid.error.code); } </script> </body> </html>Test to see ‹/›
The error attribute returns the MediaError object.
The MediaError object has a code property that contains the audio/Video error status.
IEFirefoxOperaChromeSafari
Only Internet Explorer 9 Supports the error attribute.
audio|video.error.code
Type | Description |
---|---|
Number | The code property of the MediaError object returns a numeric value that represents the audio/Video error status:
|