Merge pull request #204 from adamantike/feat/repeat-current-track
Add functionality to repeat current track
This commit is contained in:
+19
-1
@@ -58,12 +58,13 @@ type ReplayGainOptions struct {
|
|||||||
// Fallback gain intentionally omitted
|
// Fallback gain intentionally omitted
|
||||||
}
|
}
|
||||||
|
|
||||||
// The playback loop mode (LoopNone, LoopAll).
|
// The playback loop mode (LoopNone, LoopAll, LoopOne).
|
||||||
type LoopMode int
|
type LoopMode int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LoopNone LoopMode = iota
|
LoopNone LoopMode = iota
|
||||||
LoopAll
|
LoopAll
|
||||||
|
LoopOne
|
||||||
)
|
)
|
||||||
|
|
||||||
// Information about a specific audio device.
|
// Information about a specific audio device.
|
||||||
@@ -420,10 +421,23 @@ func (p *Player) SetLoopMode(mode LoopMode) error {
|
|||||||
if err := p.mpv.SetOptionString("loop-playlist", "no"); err != nil {
|
if err := p.mpv.SetOptionString("loop-playlist", "no"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := p.mpv.SetOptionString("loop-file", "no"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
case LoopAll:
|
case LoopAll:
|
||||||
if err := p.mpv.SetOptionString("loop-playlist", "inf"); err != nil {
|
if err := p.mpv.SetOptionString("loop-playlist", "inf"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := p.mpv.SetOptionString("loop-file", "no"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case LoopOne:
|
||||||
|
if err := p.mpv.SetOptionString("loop-playlist", "no"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := p.mpv.SetOptionString("loop-file", "inf"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
p.loopMode = mode
|
p.loopMode = mode
|
||||||
|
|
||||||
@@ -437,6 +451,8 @@ func (p *Player) SetNextLoopMode() error {
|
|||||||
case LoopNone:
|
case LoopNone:
|
||||||
return p.SetLoopMode(LoopAll)
|
return p.SetLoopMode(LoopAll)
|
||||||
case LoopAll:
|
case LoopAll:
|
||||||
|
return p.SetLoopMode(LoopOne)
|
||||||
|
case LoopOne:
|
||||||
return p.SetLoopMode(LoopNone)
|
return p.SetLoopMode(LoopNone)
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
@@ -650,6 +666,8 @@ func (l LoopMode) String() string {
|
|||||||
return "no"
|
return "no"
|
||||||
case LoopAll:
|
case LoopAll:
|
||||||
return "all"
|
return "all"
|
||||||
|
case LoopOne:
|
||||||
|
return "one"
|
||||||
}
|
}
|
||||||
return "UNKNOWN_LOOP_MODE"
|
return "UNKNOWN_LOOP_MODE"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,6 +193,8 @@ var (
|
|||||||
ShuffleIcon fyne.Resource
|
ShuffleIcon fyne.Resource
|
||||||
TracksIcon fyne.Resource
|
TracksIcon fyne.Resource
|
||||||
FilterIcon fyne.Resource = theme.NewThemedResource(res.ResFilterSvg)
|
FilterIcon fyne.Resource = theme.NewThemedResource(res.ResFilterSvg)
|
||||||
|
RepeatIcon fyne.Resource = theme.NewThemedResource(res.ResRepeatSvg)
|
||||||
|
RepeatOneIcon fyne.Resource = theme.NewThemedResource(res.ResRepeatoneSvg)
|
||||||
)
|
)
|
||||||
|
|
||||||
// MUST be called at startup!
|
// MUST be called at startup!
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import (
|
|||||||
"fyne.io/fyne/v2/layout"
|
"fyne.io/fyne/v2/layout"
|
||||||
"fyne.io/fyne/v2/theme"
|
"fyne.io/fyne/v2/theme"
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
|
|
||||||
|
myTheme "github.com/dweymouth/supersonic/ui/theme"
|
||||||
"github.com/dweymouth/supersonic/ui/util"
|
"github.com/dweymouth/supersonic/ui/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -41,7 +43,7 @@ func (b *miniButton) MinSize() fyne.Size {
|
|||||||
func NewAuxControls(initialVolume int) *AuxControls {
|
func NewAuxControls(initialVolume int) *AuxControls {
|
||||||
a := &AuxControls{
|
a := &AuxControls{
|
||||||
VolumeControl: NewVolumeControl(initialVolume),
|
VolumeControl: NewVolumeControl(initialVolume),
|
||||||
loop: newMiniButton(theme.MediaReplayIcon()),
|
loop: newMiniButton(myTheme.RepeatIcon),
|
||||||
}
|
}
|
||||||
a.container = container.NewHBox(
|
a.container = container.NewHBox(
|
||||||
layout.NewSpacer(),
|
layout.NewSpacer(),
|
||||||
@@ -68,8 +70,13 @@ func (a *AuxControls) OnChangeLoopMode(f func()) {
|
|||||||
func (a *AuxControls) SetLoopMode(mode string) {
|
func (a *AuxControls) SetLoopMode(mode string) {
|
||||||
if mode == "all" {
|
if mode == "all" {
|
||||||
a.loop.Importance = widget.HighImportance
|
a.loop.Importance = widget.HighImportance
|
||||||
|
a.loop.Icon = myTheme.RepeatIcon
|
||||||
|
} else if mode == "one" {
|
||||||
|
a.loop.Importance = widget.HighImportance
|
||||||
|
a.loop.Icon = myTheme.RepeatOneIcon
|
||||||
} else {
|
} else {
|
||||||
a.loop.Importance = widget.MediumImportance
|
a.loop.Importance = widget.MediumImportance
|
||||||
|
a.loop.Icon = myTheme.RepeatIcon
|
||||||
}
|
}
|
||||||
a.loop.Refresh()
|
a.loop.Refresh()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user