iOS 9 can't play audio/video files that are downloaded to device

Has anyone else had this issue?

When I use the cordova media plugin in order to play an mp3 file on iOS, I get no error or response as to why it’s not working.

I’ve gotten the ngCordova media plugin to work in my app on my ios emulator, using an external URL to play the audio file…however, I’m trying to build some functionality where basically you download the mp3 from an external source, save it to your device, and then play the file from there. I can’t seem to get it work, even though I can verify that the file does exist. Here is my code for the function:

$scope.playAudio = function() {
   document.addEventListener('deviceready', function () {
     var src = cordova.file.dataDirectory + fileSrc;
     var media = $cordovaMedia.newMedia(src);
     var iOSPlayOptions = {
           numberOfLoops: 1,
           playAudioWhenScreenIsLocked : true
     };; // iOS only!;   // Android

I should note that this functionality DOES work on my android device, but on both my ios simulator AND real device, it does absolutely nothing.

I should note that I’m using iOS 9 and xCode 7.1

Has anyone else had any issues with trying to play an audio or video file from their local device, in their app?

I am experiencing exactly the same issue. No errors or messages in the console. It simply does nothing. My Android version works fine though.
At first I thought it was something related to using native URLs (file://) vs cross platform URLs (cdvfile://) but changing that did not work either. I am using file-transfer plugin to download mp3 files and media-plugin for playback.

@snstarosciak I found the reason why playback wasn’t working. I am almost certain you are having the same problem.
The newest release of cordova-media expects a URL of the form cdvfile://path/to/mp3
If your files are stored in cordova.file.dataDirectory then you must replace your src variable with:

var src = "cdvfile://localhost/library-nosync/" + fileSrc;

I believe the above should work for you. Let me know.

1 Like

@arielf Yes that does work :smile:

In fact, here is my updated code to allow it to work properly. There is a toInternalURL() function you can use to accomplish that behavior:

scope.playAudio = function() {
document.addEventListener('deviceready', function () {
var src = cordova.file.dataDirectory + fileSrc;
$window.resolveLocalFileSystemURL(src, function(dir){

basePath = dir.toInternalURL();
media = $cordovaMedia.newMedia(basePath);
var iOSPlayOptions = {
  numberOfLoops: 1,
  playAudioWhenScreenIsLocked : true

$ = true;; // iOS only!
//; // Android


With this in mind, though…have you been able to get mp3 files working with the native HTML 5 audio player? Even when I try to set the the src like in the following, it doesn’t play, even though I know the file exists on the device:

<audio controls>
  <source src="cdvfile://localhost/library-nosync/resources/resource-1/resource-1.mp3" type="audio/mpeg">
Your browser does not support the audio element.

A similar thing happens when trying to do the same with video in the HTML 5 video tag

Html5 audio will die once you trigger cordova media startRecord. And if if you stopRecord, then Play, the html5 audio could work again. I’ve spent 3days to deal with this.

And now I have the same problem with you, online src mp3 can’t play on iOS……

What a amazing world!

==================== Update================

My problem is: iOS device can play audio record by another iOS device, can’t play audio from android device.
Seems a format issue.

im having the exact same problem bro. Like it can play the audio recorded by iphone…but not the files that were recorded by android phones