Skip to content

Commit

Permalink
Merge pull request #176 from SKProCH/fixNotifyTrackEnded
Browse files Browse the repository at this point in the history
Move firing player NotifyTrackEndedAsync after setting current item to null and updating status
  • Loading branch information
angelobreuer authored Aug 31, 2024
2 parents a046c26 + 5228bef commit 1ed9fd2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Lavalink4NET/Players/LavalinkPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,17 @@ async ValueTask ILavalinkPlayerListener.NotifyTrackEndedAsync(LavalinkTrack trac
};

try
{
await NotifyTrackEndedAsync(previousItem, endReason, cancellationToken).ConfigureAwait(false);
}
finally
{
if (Volatile.Read(ref _trackVersion) == currentTrackVersion && endReason is not TrackEndReason.Replaced)
{
CurrentItem = null;
await UpdateStateAsync(PlayerState.NotPlaying, cancellationToken).ConfigureAwait(false);
}
}
finally
{
await NotifyTrackEndedAsync(previousItem, endReason, cancellationToken).ConfigureAwait(false);
}
}

ValueTask ILavalinkPlayerListener.NotifyTrackExceptionAsync(LavalinkTrack track, TrackException exception, CancellationToken cancellationToken)
Expand Down

0 comments on commit 1ed9fd2

Please sign in to comment.