Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-7007

iOS Media Plugin: mp3 does not play

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.5.0
    • None
    • cordova-plugin-media
    • iOS

    Description

      Hello,

      I have a file named 2.mp3 in the folder APP_DIR/Library/files/app-data/main-packages/en/. My persistent file storage location is configured in config.xml ("Library" for iOS):

      <preference name="AndroidPersistentFileLocation" value="Internal" />
      <preference name="iosPersistentFileLocation" value="Library" />

      This code will play the file perfectly on Android but not on iOS:

      window.requestFileSystem(
          LocalFileSystem.PERSISTENT,
          0,
          function(fileSystem) {
              fileSystem.root.getDirectory('app-data/main-packages/en/', {create: false}, function(sourceDir){
                  sourceDir.getFile('2.mp3', {create: false}, function(file){
                      console.log('file url: ', file.toURL());
                      var mymedia = new Media(file.toURL()); 
                      mymedia.play();
                  });
              });
          },
          function(err){
              console.log('Error in requestFilesystem, err.code', err.code);                    
          }
      );
      

      The console.log() in the getFile callback will output the following files:

      Simulator: file:///Users/myUserName/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/9CE5380D-2B6C-461D-8902-071EFE8A1E70/Library/files/app-data/main-packages/en/2.mp3
      
      Device: 
      file:///var/mobile/Applications/0C73C60B-07FD-486D-8927-7568D8BBBFD2/Library/files/app-data/main-packages/en/2.mp3
      

      The files definitely exist at these locations, but I get the following error:

      2014-06-23 17:10:10.599 nnn[17439:60b] Unknown resource 'file:///Users/myUserName/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/9CE5380D-2B6C-461D-8902-071EFE8A1E70/Library/files/app-data/main-packages/en/2.mp3'
      

      If I put the same file in the app documents folder and trigger the Media plugin with the following code it will play:

      var myMedia = new Media('documents://2.mp3');
      myMedia.play();
      

      I also tried to call the Media Plugin with the "cdvfile"- Syntax. But it doesn't play either:

      var myMedia = new Media('cdvfile://Users/myUserName/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/9CE5380D-2B6C-461D-8902-071EFE8A1E70/Library/files/app-data/main-packages/en/2.mp3');
      myMedia.play();
      

      I'm running on the following Plugin versions:

      file: 1.1.0
      media: 0.2.11
      

      Any ideas ?

      Thanks in advance,
      Markus

      Attachments

        Activity

          People

            Unassigned Unassigned
            machrs Markus Sorg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: