HTMLMediaElement: error プロパティ
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
HTMLMediaElement.error
は最新のエラーの MediaError
オブジェクトです。エラーが発生していない場合は null
になります。要素が error
イベントを受け取ったら、このオブジェクトを調べることで、何が起こったのかについての詳細を決定することができます。
値
メディア要素で発生した最新のエラーを説明する MediaError
オブジェクト。 エラーが発生していない場合は null
です。
例
この例では video 要素を設けて、それにエラーハンドラーを追加しています。エラーハンドラーは単に詳細をコンソールに記録します。
js
const videoElement = document.createElement("video");
videoElement.onerror = () => {
console.error(
`Error ${videoElement.error.code}; details: ${videoElement.error.message}`,
);
};
videoElement.src = "https://example.com/bogusvideo.mp4";
仕様書
Specification |
---|
HTML # dom-media-error-dev |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
error |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
関連情報
HTMLMediaElement
:HTMLMediaElement.error
プロパティを定義しているインターフェイス<audio>
および<video>