Refactor pt. 1: move MPV player to own package and extract some types
This commit is contained in:
+3
-3
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/dweymouth/supersonic/backend"
|
||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||
"github.com/dweymouth/supersonic/player"
|
||||
"github.com/dweymouth/supersonic/player/mpv"
|
||||
"github.com/dweymouth/supersonic/ui/controller"
|
||||
"github.com/dweymouth/supersonic/ui/layouts"
|
||||
"github.com/dweymouth/supersonic/ui/widgets"
|
||||
@@ -34,7 +34,7 @@ type BottomPanel struct {
|
||||
|
||||
var _ fyne.Widget = (*BottomPanel)(nil)
|
||||
|
||||
func NewBottomPanel(p *player.Player, pm *backend.PlaybackManager, contr *controller.Controller) *BottomPanel {
|
||||
func NewBottomPanel(p *mpv.Player, pm *backend.PlaybackManager, contr *controller.Controller) *BottomPanel {
|
||||
bp := &BottomPanel{playbackManager: pm}
|
||||
bp.ExtendBaseWidget(bp)
|
||||
|
||||
@@ -93,7 +93,7 @@ func NewBottomPanel(p *player.Player, pm *backend.PlaybackManager, contr *contro
|
||||
p.SeekBackOrPrevious()
|
||||
})
|
||||
bp.Controls.OnSeek(func(f float64) {
|
||||
p.Seek(fmt.Sprintf("%d", int(f*100)), player.SeekAbsolutePercent)
|
||||
p.Seek(fmt.Sprintf("%d", int(f*100)), mpv.SeekAbsolutePercent)
|
||||
})
|
||||
|
||||
bp.AuxControls = widgets.NewAuxControls(p.GetVolume())
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/dweymouth/supersonic/backend"
|
||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||
"github.com/dweymouth/supersonic/player"
|
||||
"github.com/dweymouth/supersonic/player/mpv"
|
||||
"github.com/dweymouth/supersonic/sharedutil"
|
||||
"github.com/dweymouth/supersonic/ui/controller"
|
||||
"github.com/dweymouth/supersonic/ui/layouts"
|
||||
@@ -41,7 +42,7 @@ type nowPlayingPageState struct {
|
||||
pool *util.WidgetPool
|
||||
conf *backend.NowPlayingPageConfig
|
||||
pm *backend.PlaybackManager
|
||||
p *player.Player
|
||||
p *mpv.Player
|
||||
canRate bool
|
||||
}
|
||||
|
||||
@@ -51,7 +52,7 @@ func NewNowPlayingPage(
|
||||
pool *util.WidgetPool,
|
||||
conf *backend.NowPlayingPageConfig,
|
||||
pm *backend.PlaybackManager,
|
||||
p *player.Player, // TODO: once other player backends are supported (eg uPnP), refactor
|
||||
p *mpv.Player, // TODO: once other player backends are supported (eg uPnP), refactor
|
||||
canRate bool,
|
||||
) *NowPlayingPage {
|
||||
a := &NowPlayingPage{nowPlayingPageState: nowPlayingPageState{
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/dweymouth/supersonic/backend"
|
||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||
"github.com/dweymouth/supersonic/player"
|
||||
"github.com/dweymouth/supersonic/player/mpv"
|
||||
"github.com/dweymouth/supersonic/sharedutil"
|
||||
"github.com/dweymouth/supersonic/ui/dialogs"
|
||||
"github.com/dweymouth/supersonic/ui/util"
|
||||
@@ -474,7 +475,7 @@ func (c *Controller) ShowSettingsDialog(themeUpdateCallbk func(), themeFiles map
|
||||
devs, err := c.App.Player.ListAudioDevices()
|
||||
if err != nil {
|
||||
log.Printf("error listing audio devices: %v", err)
|
||||
devs = []player.AudioDevice{{Name: "auto", Description: "Autoselect device"}}
|
||||
devs = []mpv.AudioDevice{{Name: "auto", Description: "Autoselect device"}}
|
||||
}
|
||||
|
||||
bands := c.App.Player.Equalizer().BandFrequencies()
|
||||
@@ -491,7 +492,7 @@ func (c *Controller) ShowSettingsDialog(themeUpdateCallbk func(), themeFiles map
|
||||
dlg.OnThemeSettingChanged = themeUpdateCallbk
|
||||
dlg.OnEqualizerSettingsChanged = func() {
|
||||
// currently we only have one equalizer type
|
||||
eq := c.App.Player.Equalizer().(*player.ISO15BandEqualizer)
|
||||
eq := c.App.Player.Equalizer().(*mpv.ISO15BandEqualizer)
|
||||
eq.Disabled = !c.App.Config.LocalPlayback.EqualizerEnabled
|
||||
eq.EQPreamp = c.App.Config.LocalPlayback.EqualizerPreamp
|
||||
copy(eq.BandGains[:], c.App.Config.LocalPlayback.GraphicEqualizerBands)
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"unicode"
|
||||
|
||||
"github.com/dweymouth/supersonic/backend"
|
||||
"github.com/dweymouth/supersonic/player"
|
||||
"github.com/dweymouth/supersonic/player/mpv"
|
||||
"github.com/dweymouth/supersonic/ui/layouts"
|
||||
myTheme "github.com/dweymouth/supersonic/ui/theme"
|
||||
"github.com/dweymouth/supersonic/ui/util"
|
||||
@@ -37,7 +37,7 @@ type SettingsDialog struct {
|
||||
OnEqualizerSettingsChanged func()
|
||||
|
||||
config *backend.Config
|
||||
audioDevices []player.AudioDevice
|
||||
audioDevices []mpv.AudioDevice
|
||||
themeFiles map[string]string // filename -> displayName
|
||||
promptText *widget.RichText
|
||||
|
||||
@@ -49,7 +49,7 @@ type SettingsDialog struct {
|
||||
// TODO: having this depend on the player package for the AudioDevice type is kinda gross. Refactor.
|
||||
func NewSettingsDialog(
|
||||
config *backend.Config,
|
||||
audioDeviceList []player.AudioDevice,
|
||||
audioDeviceList []mpv.AudioDevice,
|
||||
themeFileList map[string]string,
|
||||
equalizerBands []string,
|
||||
clientDecidesScrobble bool,
|
||||
|
||||
Reference in New Issue
Block a user