chirag.jasani
chirag.jasani

Reputation: 1

how to play mp3 file in phonegap using javascript

I am developing one phoneGap application. And I used the below code for application but i got the error.

Below is my folder structure of phonegap

App
--.svn
--hooks
--platforms
--plugins
--www
-- --index.html
-- --Song
-- -- --Rang Laal.mp3

I am using below code for play the song:

<script>
    function playAudio(id) {

        var url = audioElement.getAttribute('src');
        var my_media = new Media('Song/Rang Laal.mp3',
                // success callback
                 function () { console.log("playAudio():Audio Success"); },
                // error callback
                 function (err) { console.log("playAudio():Audio Error: " + err); }
        );
        // Play audio
        my_media.play();
    }
</script>

Below is the error that i am getting

Error: SyntaxError: missing ; before statement       
          phonegap-1.4.1.js (line 671)

Actually my all .mp3 file will store in server. I have to just play from mobile. please suggest a way for that. using url we can able to play? or some plugin available in phonegap?

Awaiting for response.

Upvotes: 0

Views: 78

Answers (1)

Ovi
Ovi

Reputation: 362

i tried this plugin cordova-plugin-media which worked perfectly. Check that link

Upvotes: 1

Related Questions