Skip to content

Commit

Permalink
fix: audio slider moves on time change (#1376)
Browse files Browse the repository at this point in the history
  • Loading branch information
derschnee68 committed Jan 23, 2024
1 parent 94e7a48 commit 0abdfc6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Expand Up @@ -11,7 +11,7 @@
</div>
<div *ngIf="failedToLoad">Your browser does not support the audio element.</div>
<div *ngIf="audio" class="audio-player">
<audio id="audio" preload="auto">
<audio id="audio" preload="auto" (timeupdate)="onTimeUpdate($event)">
<source [src]="audio" type="audio/mpeg" />
</audio>
</div>
Expand Down
Expand Up @@ -66,12 +66,10 @@ export class AudioComponent implements OnInit, AfterViewInit {

ngAfterViewInit() {
this.loaded.emit(true);
const player = document.getElementById('audio') as HTMLAudioElement;
if (player) {
player.addEventListener('timeupdate', () => {
this.currentTime = player.currentTime;
});
}
}

onTimeUpdate(event: { target: HTMLAudioElement }) {
this.currentTime = event.target.currentTime;
}

togglePlay() {
Expand Down

0 comments on commit 0abdfc6

Please sign in to comment.