HTML 音频/视频 DOM error 属性
实例
获得视频的错误状态:
myVid=document.getElementById("video1");
alert(myVid.error.code);
定义和用法
error 属性返回一个 MediaError 对象。
MediaError 对象的 code 属性包含了音频/视频的错误状态。
浏览器支持
![Internet Explorer Internet Explorer](/jiaocheng/img/bubuko-jiaocheng-f3a6d480-8791-4778-91a5-df56b541a5cc.gif)
![Firefox Firefox](/jiaocheng/img/bubuko-jiaocheng-acfc8a7a-079f-407c-8402-cc47fec53b71.gif)
![Opera Opera](/jiaocheng/img/bubuko-jiaocheng-343d33be-9f3f-4e55-8ac4-8287e3401662.gif)
![Google Chrome Google Chrome](/jiaocheng/img/bubuko-jiaocheng-b214a059-9c77-40da-8da6-39e17c2a6f67.gif)
只有 Internet Explorer 9 支持 error 属性。
语法
返回值
类型
|
描述
|
Number
|
MediaError 对象的 code 属性返回一个数字值,它表示音频/视频的错误状态:
-
1 = MEDIA_ERR_ABORTED - 取回过程被用户中止
-
2 = MEDIA_ERR_NETWORK - 当下载时发生错误
-
3 = MEDIA_ERR_DECODE - 当解码时发生错误
-
4 = MEDIA_ERR_SRC_NOT_SUPPORTED - 不支持音频/视频
|