Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Path for local mp3 file from www in Phonegap IOS?

i am using phonegap audio plugin in my phonegap app. I have some audio files stored in www/audio folder.

For android i used "file:///android_asset/www/audio" to read local file.

For IOS i need help.

Thanks

like image 913
Varun Nayyar Avatar asked Dec 25 '22 23:12

Varun Nayyar


1 Answers

Finally got it, reference:link

To get path i used this function

function getPhoneGapPath() {
   var path = window.location.pathname;
   path = path.substr( path, path.length - 10 );
   return path;
};

USAGE:

For IOS:

var snd = new Media( getPhoneGapPath() + 'test.mp3' );

For Android:prepend 'file://'

var snd = new Media( 'file://' + getPhoneGapPath() + 'test.mp3' );

like image 138
Varun Nayyar Avatar answered Jan 19 '23 00:01

Varun Nayyar