Skip to content

Commit

Permalink
set playing tack on track start event
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Jul 8, 2024
1 parent f55de19 commit d7bce1c
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions disgolink/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,6 @@ func (p *playerImpl) Update(ctx context.Context, opts ...lavalink.PlayerUpdateOp
return err
}

p.track = updatedPlayer.Track
if updatedPlayer.Track != nil {
p.state.Position = updatedPlayer.Track.Info.Position
} else {
p.state.Position = 0
}
p.state.Time = lavalink.Now()
p.volume = updatedPlayer.Volume

p.voice = updatedPlayer.Voice
Expand Down Expand Up @@ -211,24 +204,18 @@ func (p *playerImpl) OnEvent(event lavalink.Event) {
case lavalink.PlayerResumeEvent:
p.paused = false

case lavalink.TrackStartEvent:
p.track = &e.Track

case lavalink.TrackEndEvent:
if p.track != nil {
e.Track = *p.track
}
if e.Reason != lavalink.TrackEndReasonReplaced && e.Reason != lavalink.TrackEndReasonStopped {
p.track = nil
}

case lavalink.TrackExceptionEvent:
if p.track != nil {
e.Track = *p.track
}
p.track = nil

case lavalink.TrackStuckEvent:
if p.track != nil {
e.Track = *p.track
}
p.track = nil

case lavalink.WebSocketClosedEvent:
Expand Down

0 comments on commit d7bce1c

Please sign in to comment.