Reputation: 47061
Here is my code (coffeescript):
toVoice = new Audio("myVoice.mp3")
toVoice.addEventListener("ended", ->console.log("ended"))
toVoice.addEventListener("error", ->console.log("error"))
toVoice.addEventListener("success", ->console.log("success"))
toVoice.addEventListener("ready", ->console.log("ready"))
I want to show a message when:
I found the ended
and error
eventListener works well, but the success
and ready
eventListener doesn't work.
I tried to find a MDN documentation about all the available events for Audio
tag/object but I didn't find one..
Does anyone have ideas about how to register a callback to detect whether an audio is valid and playable?
Upvotes: 2
Views: 2285
Reputation: 388316
There are no success or ready events for media element
I think you can try loadstart
and loadeddata
toVoice = new Audio("myVoice.mp3")
toVoice.addEventListener("ended", ->console.log("ended"))
toVoice.addEventListener("error", ->console.log("error"))
toVoice.addEventListener("canplay", ->console.log("canplay"))
toVoice.addEventListener("loadeddata", ->console.log("loadeddata"))
Upvotes: 5