This commit is contained in:
Siiiiinth
2026-01-14 22:47:31 +01:00
parent 0a368967b4
commit 0fb1e5fa17
2 changed files with 23 additions and 1 deletions
+2
View File
@@ -65,6 +65,7 @@ type playbackEngine struct {
nowPlayingIdx int
isRadio bool
loopMode LoopMode
shuffle bool
pauseAfterCurrent bool // flag to pause playback after current track ends
@@ -97,6 +98,7 @@ type playbackEngine struct {
onSongChange []func(nowPlaying mediaprovider.MediaItem, justScrobbledIfAny *mediaprovider.Track)
onPlayTimeUpdate []func(float64, float64, bool)
onLoopModeChange []func(LoopMode)
onShuffleChange []func()
onVolumeChange []func(int)
onSeek []func()
onPaused []func()
+21 -1
View File
@@ -22,8 +22,10 @@ type AuxControls struct {
widget.BaseWidget
OnChangeAutoplay func(autoplay bool)
OnChangeShuffle func(shuffle bool)
VolumeControl *VolumeControl
shuffle *IconButton
autoplay *IconButton
loop *IconButton
cast *IconButton
@@ -35,12 +37,22 @@ type AuxControls struct {
func NewAuxControls(initialVolume int, initialLoopMode backend.LoopMode, initialAutoplay bool) *AuxControls {
a := &AuxControls{
VolumeControl: NewVolumeControl(initialVolume),
shuffle: NewIconButton(myTheme.ShuffleIcon, nil),
autoplay: NewIconButton(myTheme.AutoplayIcon, nil),
loop: NewIconButton(myTheme.RepeatIcon, nil),
cast: NewIconButton(myTheme.CastIcon, nil),
showQueue: NewIconButton(myTheme.PlayQueueIcon, nil),
}
a.shuffle.IconSize = IconButtonSizeSmaller
a.shuffle.SetToolTip(lang.L("Shuffle"))
a.shuffle.OnTapped = func() {
a.SetShuffle(!a.shuffle.Highlighted)
if a.OnChangeShuffle != nil {
a.OnChangeShuffle(a.shuffle.Highlighted)
}
}
a.loop.IconSize = IconButtonSizeSmaller
a.loop.SetToolTip(lang.L("Repeat"))
a.SetLoopMode(initialLoopMode)
@@ -68,7 +80,7 @@ func NewAuxControls(initialVolume int, initialLoopMode backend.LoopMode, initial
a.VolumeControl,
container.New(
layout.NewCustomPaddedHBoxLayout(theme.Padding()*1.5),
layout.NewSpacer(), a.autoplay, a.loop, a.cast, a.showQueue, util.NewHSpace(5)),
layout.NewSpacer(), a.autoplay, a.shuffle, a.loop, a.cast, a.showQueue, util.NewHSpace(5)),
layout.NewSpacer(),
),
)
@@ -98,6 +110,14 @@ func (a *AuxControls) SetLoopMode(mode backend.LoopMode) {
}
}
func (a *AuxControls) SetShuffle(isShuffle bool) {
if isShuffle {
a.shuffle.Highlighted = true
} else {
a.shuffle.Highlighted = false
}
}
func (a *AuxControls) DisableCastButton() {
a.cast.Disable()
}