# HG changeset patch # User Lucas Thompson # Date 1487864579 0 # Node ID 1bd1a44f5dd3a7c33d1f4b86c0ad5b2d267d98a6 # Parent 13955649f5afd225f59074d0aab5bb84729b3058 Add method for seeking to specific time to the audio player service diff -r 13955649f5af -r 1bd1a44f5dd3 src/app/services/audio-player/audio-player.service.ts --- a/src/app/services/audio-player/audio-player.service.ts Wed Feb 22 18:09:50 2017 +0000 +++ b/src/app/services/audio-player/audio-player.service.ts Thu Feb 23 15:42:59 2017 +0000 @@ -44,6 +44,7 @@ this.currentObjectUrl = url; this.audioElement.pause(); this.audioElement.src = url; + this.audioElement.load(); } togglePlaying(): void { @@ -57,6 +58,16 @@ this.audioElement.volume = value; // TODO check bounds? } + seekTo(seconds: number): void { + if (seconds < 0) { + this.audioElement.currentTime = 0; + } else if (seconds < this.getDuration()) { + this.audioElement.currentTime = seconds; + } else { + this.audioElement.currentTime = this.getDuration(); + } + } + seekBy(seconds: number): void { // TODO some kind of error handling? this.audioElement.currentTime += seconds;