MediaError.message Sample

Available in Chrome 59+ | View on GitHub | Browse Samples

Background

The MediaError.message string provides, if available, any additional error message detail to help web developers debugging media player errors. Note that this sample demonstrates only a tiny fraction of such messages.

Set video with: Or

Live Output


JavaScript Snippet

let video = document.createElement('video');

video.addEventListener('error', function(event) {
  ChromeSamples.log('Error Message: ' + video.error.message);
});



emptySrcButton.addEventListener('click', function() {
  video.src= '';
});

nonExistentFileButton.addEventListener('click', function() {
  video.src = 'nonExistentFile.webm';
});

invalidFileButton.addEventListener('click', function() {
  video.src = 'https://storage.googleapis.com/media-error/no_streams.webm';
});

chooseFileButton.addEventListener('change', function() {
  const file = chooseFileButton.files[0];
  video.src = URL.createObjectURL(file);
});

video.addEventListener('canplay', function() {
  ChromeSamples.log('"canplay" event received');
});