ionic-audio icon indicating copy to clipboard operation
ionic-audio copied to clipboard

Downloaded Mp3 file is not playing on ios

Open tanvishah-syn opened this issue 8 years ago • 3 comments

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

tanvishah-syn avatar Nov 13 '17 12:11 tanvishah-syn

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.

KadjoFamian avatar Nov 22 '17 08:11 KadjoFamian

@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

arielfaur avatar Jan 29 '18 16:01 arielfaur

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

wlc002 avatar May 20 '18 09:05 wlc002