Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onFinish called while playing #212

Open
SimoneMSR opened this issue Jun 25, 2019 · 0 comments
Open

onFinish called while playing #212

SimoneMSR opened this issue Jun 25, 2019 · 0 comments

Comments

@SimoneMSR
Copy link

SimoneMSR commented Jun 25, 2019

I use the onFinish output to update my view, and show a play/stop icon near the progress bar.

The problem is that the onFinish event is fired while the audio is still playing, and not when it's completed.

Here's my HTML code

<img [src]=" (!song.track || !song.isPlaying) ? 'a.svg' : 'b.svg'">
<audio-track #providerTrack *ngIf="song.track != undefined " (onFinish)="songFinished($event)" [track]="song.track" >
     <audio-track-progress-bar dark duration progress [audioTrack]="providerTrack" [ngStyle]="{display: providerTrack.completed > 0 ? 'flex' : 'none'}">
     </audio-track-progress-bar>
</audio-track>

Here's my ts code

  songFinished(track){
    var song = this.songs.find(s => s.track && s.track.id == track.id);
    if(song && song.isPlaying){
      setTimeout(()=>{
        song.isPlaying=false;
        this.change.markForCheck();
      })
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant