How do I know a sound file was invalid?

  • 1
  • Question
  • Updated 6 years ago
  • Answered
I am displaying an audio/visual slideshow. I am using SM to play a sound, and I use onFinish to trigger the display of the next page in the slideshow.

Sometimes the sound file I'm trying to play is invalid or 404. What event or callback can I use to handle this situation? I want to be able to proceed when the sound file is no good, but onFinish never fires. I also tried onerror, ontimeout but these don't seem to fire. I tried examining the result of the load, but duration is always null, even for valid sounds...

Assistance would be great. Thanks.
Photo of Jesse Parker

Jesse Parker

  • 1 Post
  • 0 Reply Likes

Posted 6 years ago

  • 1
Photo of Scott

Scott, Official Rep

  • 3873 Posts
  • 253 Reply Likes
Make sure that you return a proper content-length header in the regular response cases, and duration should be set/defined.

For the error cases, I'd take a look at the SMSound.onload() event, which should receive a boolean indicating success/failure.

You may get better error handling using soundManager.flashVersion = 9;

If you can, I'd avoid trying to play invalid files of course. ;)