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

cordova-plugin-media not playing from local URI

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • None
    • None
    • cordova-plugin-media
    • Android 6 on Redmi 4A
      Building on Tabris JS

    Description

      Trying to play audio files from the external storage of phone.

      Went through [this plugin](https://stackoverflow.com/a/34378906/2096740) first finding the URI for a particular mp3 file. Then passed that to the cordova-plugin-media instance.

      
      // find music file URI from the sdcard
      new ExternalStorageSdcardAccess( fileHandler ).scanPath( "file:///storage/C67A-18F7/Music/" );
      function fileHandler( fileEntry ) {
          // console.log( fileEntry.name + " | " + fileEntry.toURL() );
      }    
      
      // create a button instance
      let mbutton = new Button({
        centerX: 0, top: [fbutton,100],
        text: 'play music'  
      }).appendTo(ui.contentView);    
      
      // call the play media function from the button
      mbutton.on('select', () => {
          // load and play the music:
          playAudio("file:///storage/C67A-18F7/Music/demo/testSound.mp3")
      
      });    
      
      function playAudio(url) {
          // Play the audio file at url
          var my_media = new Media(url,
              // success callback
              function () {
                  console.log("playAudio():Audio Success");
              },
              // error callback
              function (err) {
                  console.log("playAudio():Audio Error: " + err.code + err.message);
              },
              // status callback
              function (status) {
                  console.log("playAudio():Audio Status: " + status);
              }
          );
          // Play audio
          my_media.play();
          my_media.setVolume('1.0');
      }
      

      I checked the adb for log. This is what I got specifically hitting those buttons - http://paste.ubuntu.com/25767292/(http://paste.ubuntu.com/25767292/)

      incoming-operation: 'Call' on 'cordova.plugin' (o13) with method 'exec' with properties {action=create, arguments=["d39113d0-b5f5-bf2d-8a84-5afbbc6ae9a0","file:///storage/C67A-18F7/Music/demo/testSound.mp3"], callbackId=Media975330222}
      incoming-operation: 'Call' on 'cordova.plugin' (o13) with method 'exec' with properties {action=startPlayingAudio, arguments=["d39113d0-b5f5-bf2d-8a84-5afbbc6ae9a0","file:///storage/C67A-18F7/Music/demo/testSound.mp3",null], callbackId=INVALID}
      outgoing-operation: 'Notify' o13 of 'finish' with arguments {message=S01 Media975330222 s, status=1, keepCallback=false, callbackId=Media975330222}
      ExtMediaPlayer-JNI: env->IsInstanceOf fails
      MediaPlayer-JNI: JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0
      ExtMediaPlayer-JNI: env->IsInstanceOf fails
      MediaPlayer-JNI: JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0
      
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            iamjkdn iamjkdn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: