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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
a.Config.LocalPlayback.Volume = clamp(a.Config.LocalPlayback.Volume, 0, 100)
|
||||
a.Player.SetVolume(a.Config.LocalPlayback.Volume)
|
||||
|
||||
a.Player.SetAudioDevice(a.Config.LocalPlayback.AudioDeviceName)
|
||||
|
||||
rgainOpts := []string{ReplayGainNone, ReplayGainAlbum, ReplayGainTrack}
|
||||
if !sharedutil.StringSliceContains(rgainOpts, a.Config.ReplayGain.Mode) {
|
||||
a.Config.ReplayGain.Mode = ReplayGainNone
|
||||
|
||||
@@ -49,6 +49,7 @@ type PlaylistPageConfig struct {
|
||||
}
|
||||
|
||||
type LocalPlaybackConfig struct {
|
||||
AudioDeviceName string
|
||||
AudioExclusive bool
|
||||
InMemoryCacheSizeMB int
|
||||
Volume int
|
||||
@@ -108,6 +109,8 @@ func DefaultConfig(appVersionTag string) *Config {
|
||||
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
||||
},
|
||||
LocalPlayback: LocalPlaybackConfig{
|
||||
// "auto" is the name to pass to MPV for autoselecting the output device
|
||||
AudioDeviceName: "auto",
|
||||
AudioExclusive: false,
|
||||
InMemoryCacheSizeMB: 30,
|
||||
Volume: 100,
|
||||
|
||||
@@ -406,6 +406,10 @@ func (p *Player) ListAudioDevices() ([]AudioDevice, error) {
|
||||
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) {
|
||||
playpos, err := p.mpv.GetProperty(propName, mpv.FORMAT_INT64)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user