Open muhammadirfan247 opened 4 years ago
I'm playing audio files in the Ionic app with it's path set through an API. When I start an audio it is working fine. But when I pause and play it starts from the beginning. Here is my play function:
play(track) { if (this.player) { this.player.unload(); this.player.stop(); } this.player = new Howl({ src: [track.file_path], html5: true, onplay: () => { this.activeTrack = track; this.isPlaying = true; this.updateProgress(); }, onload: () => {}, onend: () => { this.isPlaying = false; }, }); this.player.play(); }
And this is Toggle Function:
togglePlayer(pause) { if (this.activeTrack != null) { this.isPlaying = !pause; if (pause) { this.player.pause(); } else { this.player.play(); } } }
And here is updateProgress() and seek()
updateProgress() { let seek = this.player.seek(); this.progress = (seek / this.player.duration()) * 100 || 0; setTimeout(() => { this.updateProgress(); }, 1000); } seek() { if (this.activeTrack != null) { let valueAt = +this.range.value; let duration = this.player.duration(); this.player.seek(duration * (valueAt / 100)); } }
@muhammadirfan247 found a solution for this? This issue is only when html5:true, I dont know how to fix it
I'm playing audio files in the Ionic app with it's path set through an API. When I start an audio it is working fine. But when I pause and play it starts from the beginning. Here is my play function:
And this is Toggle Function:
And here is updateProgress() and seek()