Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the MediaError message attribute if available #1727

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bausmeier
Copy link

Issue/Feature

Prefer the message attribute on the error over the code attribute because it contains more specific diagnostic information.

Related Issues

I couldn't find any.

Solution

The message attribute on the MediaError object returned by HTMLMediaElement.error contains specific diagnostic details about the error if available, or an empty string otherwise.

If this message is available then it will be passed with the loaderror, otherwise the code will be passed as before.

See https://html.spec.whatwg.org/multipage/media.html#error-codes.

Reproduction/Testing

Trigger a media error, and observe that a string message is provided to onloaderror instead of a code.

The easiest option is to use a non-existent source:

const howl = new Howl({
  src: 'non-existent.webm',
  html5: true,
  onloaderror(id, error) {
    console.log(error)
  },
})
howl.play()

Which will print something like Failed to init decoder instead of 4.

Breaking Changes

The onloaderror was already being called with a message in most cases, so I wouldn't consider this a breaking change.

The `message` attribute on the `MediaError` object returned by
`HTMLMediaElement.error` contains specific diagnostic details about the
error if available, or an empty string otherwise.

If this message is available then it will be passed with the
`loaderror`, otherwise the code will be passed as before.

See https://html.spec.whatwg.org/multipage/media.html#error-codes.
@bausmeier
Copy link
Author

Context for this is that we're receiving error reports that just say 3 from which we can determine that it's related to decoding the audio, but doesn't give us much to go on. We're hoping that the actual error message will give us more to work with for debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant