You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/09/11 07:27:52 UTC

[GitHub] [cordova-plugin-media] rushabhmakwana-multidots opened a new issue #254: How to get media file duration before playing it?

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:
users@infra.apache.org


With regards,
Apache Git Services

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