Skip to content

Commit

Permalink
fix: avoid double skip on track end
Browse files Browse the repository at this point in the history
  • Loading branch information
devgianlu committed Jun 28, 2024
1 parent 2c982d0 commit ba696c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cmd/daemon/controls.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ func (p *AppPlayer) handlePlayerEvent(ev *player.Event) {
})
}
case player.EventTypeStopped:
// do nothing
p.app.server.Emit(&ApiEvent{
Type: ApiEventTypeStopped,
Data: ApiEventDataStopped{
PlayOrigin: p.state.playOrigin(),
},
})
default:
panic("unhandled player event")
}
Expand Down
5 changes: 4 additions & 1 deletion player/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ loop:
_ = out.Close()
out = nil
outErr = make(<-chan error)

log.Tracef("closed output device because of stop command")
}

cmd.resp <- struct{}{}
Expand Down Expand Up @@ -219,7 +221,8 @@ loop:
out = nil
outErr = make(<-chan error)

p.ev <- Event{Type: EventTypeNotPlaying}
log.Tracef("cleared closed output device")

p.ev <- Event{Type: EventTypeStopped}
case <-source.Done():
p.ev <- Event{Type: EventTypeNotPlaying}
Expand Down

0 comments on commit ba696c7

Please sign in to comment.