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

前端 未结 2 1400
陌清茗
陌清茗 2021-01-14 02:08

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

2条回答
  •  时光说笑
    2021-01-14 02:51

    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' );

提交回复
热议问题