Skip to content

Commit

Permalink
fix: typo in seek bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
devgianlu committed Apr 17, 2024
1 parent 0c7a32f commit e122f2e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion player/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func (p *Player) NewStream(spotId librespot.SpotifyId, bitrate int, mediaPositio
return nil, fmt.Errorf("unsupported channels: %d", stream.Channels)
}

if err := stream.SetPositionMs(min(0, max(mediaPosition, int64(media.Duration())))); err != nil {
if err := stream.SetPositionMs(max(0, min(mediaPosition, int64(media.Duration())))); err != nil {
return nil, fmt.Errorf("failed seeking stream: %w", err)
}

Expand Down
2 changes: 1 addition & 1 deletion player/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (s *Stream) Stop() {
}

func (s *Stream) SeekMs(pos int64) error {
pos = min(0, max(pos, int64(s.Media.Duration())))
pos = max(0, min(pos, int64(s.Media.Duration())))

resp := make(chan any, 1)
s.p.cmd <- playerCmd{typ: playerCmdSeek, data: pos, resp: resp}
Expand Down

0 comments on commit e122f2e

Please sign in to comment.