You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The read-only property **`MediaError.message`** returns a
12
-
human-readable string offering specific
13
-
diagnostic details related to the error described by the `MediaError` object,
14
-
or an empty string (`""`) if no diagnostic information can be determined or
15
-
provided.
11
+
The read-only property **`MediaError.message`** returns a human-readable string offering specific diagnostic details related to the error described by the `MediaError` object, or an empty string (`""`) if no diagnostic information can be determined or provided.
16
12
17
13
## Value
18
14
19
-
A string providing a detailed, specific explanation of what went
20
-
wrong and possibly how it might be fixed. This is _not_ a generic description of
21
-
the {{domxref("MediaError.code")}} property's value, but instead goes deeper into the
22
-
specifics of this particular error and its circumstances. If no specific details are
23
-
available, this string is empty.
15
+
A string providing a detailed, specific explanation of what went wrong and possibly how it might be fixed. This is _not_ a generic description of the {{domxref("MediaError.code")}} property's value, but instead goes deeper into the specifics of this particular error and its circumstances.
16
+
If no specific details are available, this string is empty.
24
17
25
18
## Examples
26
19
27
-
This example creates an {{HTMLElement("audio")}} element, establishes an error handler
28
-
for it, then lets the user click buttons to choose whether to assign a valid audio file
29
-
or a missing file to the element's [`src`](/en-US/docs/Web/HTML/Reference/Elements/audio#src) attribute. The error
30
-
handler outputs a message to a box onscreen describing the error, including both the
31
-
`code` and the `message`.
20
+
This example creates an {{HTMLElement("audio")}} element, establishes an error handler for it, then lets the user click buttons to choose whether to assign a valid audio file or a missing file to the element's [`src`](/en-US/docs/Web/HTML/Reference/Elements/audio#src) attribute.
21
+
The error handler outputs a message to a box onscreen describing the error, including both the `code` and the `message`.
32
22
33
-
Only the relevant parts of the code are displayed; you can [see the complete source code here](https://github.com/mdn/dom-examples/tree/main/media/mediaerror).
23
+
```html
24
+
<audiocontrolsid="audio"></audio>
25
+
<div>
26
+
<buttonid="valid-button">Valid File</button>
27
+
<buttonid="invalid-button">Missing File</button>
28
+
</div>
29
+
<preid="log"></pre>
30
+
```
34
31
35
-
The example creates an {{HTMLElement("audio")}} element and lets the user assign either
36
-
a valid music file to it, or a link to a file which doesn't exist. This lets us see the
37
-
behavior of the {{domxref("HTMLMediaElement/error_event", "error")}} event handler, which is received by an event handler
38
-
we add to the `<audio>` element itself.
32
+
The example creates an {{HTMLElement("audio")}} element and lets the user assign either a valid music file to it, or a link to a file which doesn't exist.
33
+
This lets us see the behavior of the {{domxref("HTMLMediaElement/error_event", "error")}} event handler, which is received by an event handler we add to the `<audio>` element itself.
This gets the {{domxref("MediaError")}} object describing the error from the
77
-
{{domxref("HTMLMediaElement.error", "error")}} property on the
78
-
{{domxref("HTMLAudioElement")}} representing the audio player. The error's
79
-
{{domxref("MediaError.code", "code")}} attribute is checked to determine a generic error
80
-
message to display, and, if `message` is not empty, it's appended to provide
81
-
additional details. Then the resulting text is output to the log.
82
-
83
-
### Result
84
-
85
-
You can try out this example below, and can [see the example in action outside this page here](https://mdn.github.io/dom-examples/media/mediaerror/).
83
+
This gets the {{domxref("MediaError")}} object describing the error from the {{domxref("HTMLMediaElement.error", "error")}} property on the {{domxref("HTMLAudioElement")}} representing the audio player.
84
+
The error's {{domxref("MediaError.code", "code")}} attribute is checked to determine a generic error message to display, and, if `message` is not empty, it's appended to provide additional details.
0 commit comments