add config option for audio device name and set it on startup
This commit is contained in:
@@ -56,9 +56,12 @@ func StartupApp(appName, appVersionTag, configFile, latestReleaseURL string) (*A
|
|||||||
if err := a.initMPV(); err != nil {
|
if err := a.initMPV(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
a.Config.LocalPlayback.Volume = clamp(a.Config.LocalPlayback.Volume, 0, 100)
|
a.Config.LocalPlayback.Volume = clamp(a.Config.LocalPlayback.Volume, 0, 100)
|
||||||
a.Player.SetVolume(a.Config.LocalPlayback.Volume)
|
a.Player.SetVolume(a.Config.LocalPlayback.Volume)
|
||||||
|
|
||||||
|
a.Player.SetAudioDevice(a.Config.LocalPlayback.AudioDeviceName)
|
||||||
|
|
||||||
rgainOpts := []string{ReplayGainNone, ReplayGainAlbum, ReplayGainTrack}
|
rgainOpts := []string{ReplayGainNone, ReplayGainAlbum, ReplayGainTrack}
|
||||||
if !sharedutil.StringSliceContains(rgainOpts, a.Config.ReplayGain.Mode) {
|
if !sharedutil.StringSliceContains(rgainOpts, a.Config.ReplayGain.Mode) {
|
||||||
a.Config.ReplayGain.Mode = ReplayGainNone
|
a.Config.ReplayGain.Mode = ReplayGainNone
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ type PlaylistPageConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type LocalPlaybackConfig struct {
|
type LocalPlaybackConfig struct {
|
||||||
|
AudioDeviceName string
|
||||||
AudioExclusive bool
|
AudioExclusive bool
|
||||||
InMemoryCacheSizeMB int
|
InMemoryCacheSizeMB int
|
||||||
Volume int
|
Volume int
|
||||||
@@ -108,6 +109,8 @@ func DefaultConfig(appVersionTag string) *Config {
|
|||||||
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
||||||
},
|
},
|
||||||
LocalPlayback: LocalPlaybackConfig{
|
LocalPlayback: LocalPlaybackConfig{
|
||||||
|
// "auto" is the name to pass to MPV for autoselecting the output device
|
||||||
|
AudioDeviceName: "auto",
|
||||||
AudioExclusive: false,
|
AudioExclusive: false,
|
||||||
InMemoryCacheSizeMB: 30,
|
InMemoryCacheSizeMB: 30,
|
||||||
Volume: 100,
|
Volume: 100,
|
||||||
|
|||||||
@@ -406,6 +406,10 @@ func (p *Player) ListAudioDevices() ([]AudioDevice, error) {
|
|||||||
return devices, nil
|
return devices, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Player) SetAudioDevice(deviceName string) error {
|
||||||
|
return p.mpv.SetPropertyString("audio-device", deviceName)
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Player) getInt64Property(propName string) (int64, error) {
|
func (p *Player) getInt64Property(propName string) (int64, error) {
|
||||||
playpos, err := p.mpv.GetProperty(propName, mpv.FORMAT_INT64)
|
playpos, err := p.mpv.GetProperty(propName, mpv.FORMAT_INT64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user