Cordova-media-plugin not playing on ios


#1

I can get a url to an external server to work with the code and play, but I cannot get the code to work with playing audio on IOS locally. It “plays” but there is no audio, I have tried “mp3” and also “m4a”

Some simple code:

let src = "mp3/test.mp3";
let media = new Media(WebAppLocalServer.localFileSystemUrl('cdv'+cordova.file.applicationDirectory+"www/application/app"+src),
        (success)=>{console.log("success");console.log(success);media.play();},
        (success)=>{console.log("error");console.log(success);},
        (success)=>{console.log("status");console.log(success);},
      );
    media.play();

The code will show a “status” “2” (which means running), but I can’t hear anything!? If I use “file” instead of cdv it says “Cannot use audio file…”

Also media.getDuration() returns 0


#2

Although I haven’t tested audio files, meteor does not support the cdvfile format without a hack. As far as I know, the function you used only supports the file:/// format


#3

Oh that is good to know, sadly “file:///” isn’t working either, but now at least I have a better grasp of the issue.


#4

Please note that replacing cdvfile:// with file:/// won’t work. You need to use the file url format which is completely different from the cdvfile format. I’m not near my laptop now so l cannot check but official cordova plugins can return a native url and a file url both pointing to the same file.