arielfaur / ionic-audio

An audio player for Ionic 3 and Angular 4. Works with HTML 5 audio or native audio using Cordova Media plugin.
http://arielfaur.github.io/ionic-audio/2.0/index.html
MIT License
321 stars 163 forks source link

Downloaded Mp3 file is not playing on ios #168

Open tanvishah-syn opened 7 years ago

tanvishah-syn commented 7 years ago

Hello, I am using ionic native audio version 3.2.0 and file transfer plugin. After Downloading file is stored in documentDirectory after this I will try to play mp3 file from local path. This same thing works perfectly on android but it's not working on IOS. Given below is a path:

file:///Users/{{username}}/Library/Developer/CoreSimulator/Devices/B56ADA53-1DE1-41FF-A429-C2DF15E1BF38/data/Containers/Data/Application/F3A028DE-069D-4F7B-855A-682E0FE3E183/Documents/File11.mp3

I am getting an error as [Error] Not allowed to load local resource: file:///Users/abc/Library/Developer/CoreSimulator/Devices/B56ADA53-1DE1-41FF-A429-C2DF15E1BF38/data/Containers/Data/Application/F3A028DE-069D-4F7B-855A-682E0FE3E183/Documents/File11.mp3

KadjoFamian commented 7 years ago

I am not familiar to ios related stuff, but did you check for permissions for example. i don't really know how it works, but you could start there.

arielfaur commented 6 years ago

@tanuShah Make sure you have the right path in iOS. Take a look at the File plugin which explains the file system layout on the different platforms. It also defines some constants you can use to point to files: https://github.com/apache/cordova-plugin-file#file-system-layouts

wlc002 commented 6 years ago

i solved this problem ,the reason is that ios expects a URL of the form "cdvfile://path/to/mp3" so i use toInternalURL() ,it worked! this.file.resolveLocalFilesystemUrl(encodeURI(audioFile)).then((entry) => { audio.src = entry.toInternalURL();

  });

this link may help : https://forum.ionicframework.com/t/ios-9-cant-play-audio-video-files-that-are-downloaded-to-device/37580