mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2025-12-06 18:32:50 +08:00
44 lines
931 B
Go
44 lines
931 B
Go
package mpv
|
|
|
|
import (
|
|
"AynaLivePlayer/core/events"
|
|
"AynaLivePlayer/global"
|
|
"AynaLivePlayer/pkg/eventbus"
|
|
)
|
|
|
|
type playerConfig struct {
|
|
Volume float64
|
|
AudioDevice string
|
|
DisplayMusicCover bool
|
|
}
|
|
|
|
func (p *playerConfig) Name() string {
|
|
return "Player"
|
|
}
|
|
|
|
func (p *playerConfig) OnLoad() {
|
|
return
|
|
}
|
|
|
|
func (p *playerConfig) OnSave() {
|
|
return
|
|
}
|
|
|
|
var cfg = &playerConfig{
|
|
Volume: 100,
|
|
DisplayMusicCover: true,
|
|
}
|
|
|
|
func restoreConfig() {
|
|
_ = global.EventBus.Publish(events.PlayerVolumeChangeCmd, events.PlayerVolumeChangeCmdEvent{
|
|
Volume: cfg.Volume,
|
|
})
|
|
global.EventBus.Subscribe("", events.PlayerPropertyVolumeUpdate, "player.config.volume", func(evnt *eventbus.Event) {
|
|
data := evnt.Data.(events.PlayerPropertyVolumeUpdateEvent)
|
|
cfg.Volume = data.Volume
|
|
})
|
|
_ = global.EventBus.Publish(events.PlayerSetAudioDeviceCmd, events.PlayerSetAudioDeviceCmdEvent{
|
|
Device: cfg.AudioDevice,
|
|
})
|
|
}
|