rushabhmakwana-multidots opened a new issue #254: How to get media file 
duration before playing it?
URL: https://github.com/apache/cordova-plugin-media/issues/254
 
 
   I am developing an ionic app in which I need to display media duration 
immediately after downloading it. I tried to show it with the below code:
   
       let audio = this.media.create('XXXX');
       let audioDuration = audio.getDuration(); // it returns me 'NaN'.
   
   But when I play this audio and trying to get the audio duration in 
getCurrentPosition() function it gives the audio duration. For this, my code is 
below:
   
       let audio = this.media.create('XXXX');
       audio.play(); 
   
       this.audio.getCurrentPosition(
       // success callback
         (position) => {
           if (position > -1) {
             var seconds = this.audio.getDuration(); // returns no.of seconds.
          }
        },
         // error callback
         (e) => {
           console.log("Error getting pos=" + e);
         }
       );
   
   How can I get the audio duration before playing it? Please help.
   
   
   
   
    

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org

Reply via email to