English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML-Referenzhandbuch

Vollständiges Verzeichnis der HTML-Tags

HTML Audio/Video-DOM error-Eigenschaft

Die error-Eigenschaft ist der zuletzt aufgetretene MediaError-Objekt; wenn es keine Fehler gibt, ist es null. Wenn das Projekt den error-Event erhält, kann es detaillierte Informationen darüber erhalten, was passiert ist, wenn dieses Objekt überprüft wird.

 HTML Audio/Video DOM Reference Manual

Online-Beispiel

Video-Fehlerstatus erhalten:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML-Audio/Video error-Eigenschaft verwenden-Grund教程(oldtoolbag.com)</<title>
</<head>
<body>
<button onclick="getError()" type="button">Videofehlerstatus erhalten</button>
<br> 
<video id="video1" controls="controls" autoplay="autoplay">
  <source src="movie_no_exist.mp4" type="video/mp4">
  <source src="movie_no_exist.ogg" type="video/ogg">
  Ihr Browser unterstützt keine     HTML5 video     Etikett.
</video>
<script>
myVid=document.getElementById("video1);
function getError()
{ 
  alert(myVid.error.code);
} 
</script> 
</body>
</html>
Test to see ‹/›

Definition and Usage

The error attribute returns the MediaError object.
The code property of the MediaError object contains audio/Video error state.

Browser compatibility

IEFirefoxOperaChromeSafari

Only Internet Explorer 9 Supports the error attribute.

Syntax

audio|video.error.code

Return value

TypeDescription
NumberThe code property of the MediaError object returns a numeric value that indicates the audio/Video error state:
  • 1 = MEDIA_ERR_ABORTED - Process was aborted by the user

  • 2 = MEDIA_ERR_NETWORK - Error occurred during download

  • 3 = MEDIA_ERR_DECODE - Error occurred during decoding

  • 4 = MEDIA_ERR_SRC_NOT_SUPPORTED - Audio not supported/Video

 HTML Audio/Video DOM Reference Manual