Search code examples
cordovacordova-plugins

How to loop a audio in phonegap?


I'm using phonegap 2.2.0. I tried some code to loop the audio for playing without interruption but it is not working on my android device. It plays only once. Here is my code:

 


    function playAudio(url) {

        var my_media = new Media(url,
            function() {
                console.log("playAudio():Audio Success");
            },
            function(err) {
                console.log("playAudio():Audio Error: "+err);
            },
            function(status) {
                console.log("playAudio():Audio Status: "+status);
            }
        });

        // Play audio
        my_media.play({numberOfLoops:99});
    }


Can you tell me what is wrong here?


Solution

  • Looping is not supported for Android yet in Phonegap - so numberOfLoops does nothing except on iOS devices.