Cordova Media Plugin media.getDuration

I am using ionic to build a stream audio player (spotify like) and trying to build the player using cordova media plugin.

I tried to follow the instruction in Cordova media plugin page to get duration, but it showing a different result.

The audio file (.ogg) that I upload has 4:18, but in my android, it only has 3:17. Is there something wrong with the code?

here is my getDuration Method

var self = this;
var counter = 0;
var timerDur = $interval(function() {
   counter = counter + 100;
   if (counter > 2000) {
      $interval.cancel(timerDur);
   }
   var dur = self.media.getDuration();
   if (dur > 0) {
      $interval.cancel(timerDur);
      //document.getElementById('audio_duration').innerHTML = (dur) + " sec";
      self.duration = dur * 1000;
   }}, 100);

Were you be able to resolve this issue? I’m badly stuck at this for hours. Any help would be much appreciated!

Hi… I haven’t solve the issue… so I change the flow… I just sent the info of the length audio from backend…

Best Regards

Thanks for your response and info! @vahndee

If anyone still looking for the answer, you can refer to ionic thread or stackoverflow thread