Html5 - Callback when media is ready on iPad wont work

Posted by Kap on Stack Overflow See other posts from Stack Overflow or by Kap
Published on 2012-03-26T17:43:28Z Indexed on 2012/03/27 17:29 UTC
Read the original article Hit count: 291

I'm trying to add a callback to a HTML5 audio element on an iPad. I added an eventlistener to the element, the myOtherThing() starts but there is no sound. If I pause and the play the sound again the audio starts. This works in chrome. Does anyone have an idea how I can do this?

    myAudioElement.src = "path_to_file";
    addEventListener("canplay", function(){
        myAudioElement.play();
        myOtherThing.start();
    });

SOLVED

Just wanted to share my solution here, just in case someone else needs it. As far as I understand the iPad does not trigger any events without user interactions. So to be able to use "canply", "playing" and all the other events you need to use the built in media controller. Once you press play in that controller, the events gets triggered. After that you can use your custom interface.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about javascript-events