getDuration() { this.curr_playing_file = this.media.create(this.play_The_track); // On occassions, the plugin only gives duration of the file if the file is played // at least once this.curr_playing_file.play(); this.curr_playing_file.setVolume(0.0); // you don't want users to notice that you are playing the file const self = this; // The plugin does not give the correct duration on playback start // need to check for duration repeatedly let temp_duration = self.duration; this.get_duration_interval = setInterval(() => { if (self.duration === -1 || !self.duration) { self.duration = ~~(self.curr_playing_file.getDuration()); // make it an integer } else { if (self.duration !== temp_duration) { temp_duration = self.duration; } else { self.curr_playing_file.stop(); self.curr_playing_file.release(); clearInterval(self.get_duration_interval); this.display_duration = this.toHHMMSS(self.duration); self.setToPlayback(); } } }, 100); }