Skip to content

Instantly share code, notes, and snippets.

@yoannmoinet
Created November 29, 2017 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoannmoinet/c3b862a7223880efe30d9967b9fc34e3 to your computer and use it in GitHub Desktop.
Save yoannmoinet/c3b862a7223880efe30d9967b9fc34e3 to your computer and use it in GitHub Desktop.
Video missing support error handling.
const video = document.querySelector('video');
video.addEventListener('error', () => {
switch (video.error.code) {
case video.error.MEDIA_ERR_DECODE:
case video.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
// Video format not supported.
break;
case video.error.MEDIA_ERR_ABORTED:
case video.error.MEDIA_ERR_NETWORK:
default:
// Any other errors, handle this differently.
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment