Add Loop functionality to player controls
Adding the Loop functionality, along with the Player changes to support it, and a button to the player controls. `Player` now has a `loopMode` attribute, which determines whether it should loop. At the moment, only the following modes are supported: * `LoopNone`: Disables loop. * `LoopAll`: Enables loop for the entire playlist queue. This has been designed as an enum, to support other modes in the future (e.g. loop for the current track only). It depends on the `loop` functionality provided by MPV (using the [`loop-playlist` option](https://mpv.io/manual/master/#options-loop-playlist)), so no custom logic is needed to reset the currently playing index.
This commit is contained in:
@@ -46,6 +46,9 @@ func NewBottomPanel(p *player.Player, contr *controller.Controller) *BottomPanel
|
||||
p.OnStopped(func() {
|
||||
bp.Controls.SetPlaying(false)
|
||||
})
|
||||
p.OnLoopModeChanged(func(mode string) {
|
||||
bp.Controls.SetLoopMode(mode)
|
||||
})
|
||||
|
||||
bp.NowPlaying = widgets.NewNowPlayingCard()
|
||||
bp.NowPlaying.OnShowCoverImage = func() {
|
||||
@@ -87,6 +90,9 @@ func NewBottomPanel(p *player.Player, contr *controller.Controller) *BottomPanel
|
||||
bp.Controls.OnSeek(func(f float64) {
|
||||
p.Seek(fmt.Sprintf("%d", int(f*100)), player.SeekAbsolutePercent)
|
||||
})
|
||||
bp.Controls.OnChangeLoopMode(func() {
|
||||
p.SetNextLoopMode()
|
||||
})
|
||||
|
||||
bp.AuxControls = widgets.NewAuxControls(p.GetVolume())
|
||||
bp.AuxControls.VolumeControl.OnVolumeChanged = func(v int) {
|
||||
|
||||
Reference in New Issue
Block a user