Thuộc tính lỗi DOM Audio / Video HTML

❮ Tham chiếu DOM Audio / Video HTML

Thí dụ

Nhận trạng thái lỗi của video:

var vid = document.getElementById("myVideo");
alert(vid.error.code);

Định nghĩa và Cách sử dụng

Thuộc tính lỗi trả về một đối tượng MediaError.

Đối tượng MediaError có thuộc tính mã chứa trạng thái lỗi của âm thanh / video.


Hỗ trợ trình duyệt

Các số trong bảng chỉ định phiên bản trình duyệt đầu tiên hỗ trợ đầy đủ thuộc tính.

Property
error Not supported 9.0  Not supported Not supported Not supported

Cú pháp

audio|video.error.code

Giá trị trả lại

Type Description
Number The code property of the MediaError Object returns a number representing the error state of the audio/video:
  • 1 = MEDIA_ERR_ABORTED - fetching process aborted by user
  • 2 = MEDIA_ERR_NETWORK - error occurred when downloading
  • 3 = MEDIA_ERR_DECODE - error occurred when decoding
  • 4 = MEDIA_ERR_SRC_NOT_SUPPORTED - audio/video not supported

❮ Tham chiếu DOM Audio / Video HTML