3

If the audio object is initialized with a broken link then it won't play a sound.

var audio = new Audio(link); // link = "www.badlink.com/sound.mp3"
audio.play();

How do I fire an error message if the sound doesn't play?

I've tried:

  1. checking the link with xmlhttp request for 404, but that doesn't work because the link is on an external domain.
  2. firing an error on abort, error, suspend, and other events. They are never triggered.

Thanks in advance.

Community
  • 1
  • 1
K L
  • 39
  • 3
  • 3
    this has already been discussed. http://stackoverflow.com/questions/13614803/how-to-check-if-html5-audio-has-reached-different-errors – mr-wildcard Jan 18 '16 at 16:56

0 Answers0