Khalid
Khalid

Reputation: 4808

Phonegap unable to read local audio file

Can someone tell me what I did wrong ?

I have created a cordova project, I've added android platform, I have added files plugin and media plugin into my project.

I tried the Audio object, and the Media object, I tried accessing my files with all kind of paths I found on the web

file:///data/data/abc.abc.abc/files/files/audio/au.wav
file://android_asset/www/audio/au.wav
www/audio/au.wav
/www/audio/au.wav
asset/www/audio/au.wav
/www/audio/au.wav
audio/au.wav
/audio/au.wav
...

I tried this

var au = new Audio(path);
au.play();

and this

var au = new Media(path,success,fail);
success = function(){
   // log
}
fail = function(){
   // log
}
au.play();

Nothing worked for me. Can you tell me what's wrong ?

Upvotes: 0

Views: 221

Answers (1)

Varsha Vijayvargiya
Varsha Vijayvargiya

Reputation: 771

You can use tag. iTs working in phonegap....

 <html>
 <body>

<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Mobile support the audio element.
</audio>

</body>
</html>

Upvotes: 1

Related Questions