add AudioExclusive mode
This commit is contained in:
+1
-1
@@ -80,7 +80,7 @@ func (a *App) readConfig() {
|
|||||||
|
|
||||||
func (a *App) initMPV() error {
|
func (a *App) initMPV() error {
|
||||||
p := player.NewWithClientName(AppName)
|
p := player.NewWithClientName(AppName)
|
||||||
if err := p.Init(); err != nil {
|
if err := p.Init(a.Config.LocalPlayback.AudioExclusive); err != nil {
|
||||||
return fmt.Errorf("failed to initialize mpv player: %s", err.Error())
|
return fmt.Errorf("failed to initialize mpv player: %s", err.Error())
|
||||||
}
|
}
|
||||||
a.Player = p
|
a.Player = p
|
||||||
|
|||||||
+4
-2
@@ -48,7 +48,8 @@ type PlaylistPageConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type LocalPlaybackConfig struct {
|
type LocalPlaybackConfig struct {
|
||||||
Volume int
|
AudioExclusive bool
|
||||||
|
Volume int
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@@ -90,7 +91,8 @@ func DefaultConfig() *Config {
|
|||||||
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
||||||
},
|
},
|
||||||
LocalPlayback: LocalPlaybackConfig{
|
LocalPlayback: LocalPlaybackConfig{
|
||||||
Volume: 100,
|
AudioExclusive: false,
|
||||||
|
Volume: 100,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -77,7 +77,7 @@ func NewWithClientName(c string) *Player {
|
|||||||
|
|
||||||
// Initializes the Player and makes it ready for playback.
|
// Initializes the Player and makes it ready for playback.
|
||||||
// Most Player functions will return ErrUnitialized if called before Init.
|
// Most Player functions will return ErrUnitialized if called before Init.
|
||||||
func (p *Player) Init() error {
|
func (p *Player) Init(audioExclusive bool) error {
|
||||||
if !p.initialized {
|
if !p.initialized {
|
||||||
m, err := CreateMPV()
|
m, err := CreateMPV()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -96,6 +96,10 @@ func (p *Player) Init() error {
|
|||||||
}
|
}
|
||||||
m.SetOption("volume", MPVFormatInt64, p.vol)
|
m.SetOption("volume", MPVFormatInt64, p.vol)
|
||||||
|
|
||||||
|
if audioExclusive {
|
||||||
|
m.SetOptionString("audio-exclusive", "yes")
|
||||||
|
}
|
||||||
|
|
||||||
if p.clientName != "" {
|
if p.clientName != "" {
|
||||||
m.SetOptionString("audio-client-name", p.clientName)
|
m.SetOptionString("audio-client-name", p.clientName)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user