add usesysplaylist option

This commit is contained in:
aynakeya
2024-08-25 10:42:18 -07:00
parent 2056bd310a
commit 23d6944a52
8 changed files with 55 additions and 25 deletions

View File

@@ -58,7 +58,9 @@ func main() {
global.EventManager.Start()
}()
gui.MainWindow.ShowAndRun()
global.Logger.Info("closing internal server")
internal.Stop()
global.Logger.Infof("closing event manager")
global.EventManager.Stop()
if *dev {
i18n.SaveTranslation()

View File

@@ -52,6 +52,14 @@
"en": "Basic",
"zh-CN": "基础设置"
},
"gui.config.basic.use_system_playlist": {
"en": "Play system playlist when no music",
"zh-CN": "是否播放闲置歌单(实验性)"
},
"gui.config.basic.use_system_playlist.prompt": {
"en": "Yes",
"zh-CN": "是"
},
"gui.history.artist": {
"en": "Artist",
"zh-CN": "歌手"

View File

@@ -124,6 +124,13 @@ func (b *bascicConfig) CreatePanel() fyne.CanvasObject {
checkUpdateBtn := widget.NewButton(i18n.T("gui.config.basic.check_update"), func() {
global.EventManager.CallA(events.CheckUpdateCmd, events.CheckUpdateCmdEvent{})
})
b.panel = container.NewVBox(randomPlaylist, skipWhenErr, outputDevice, checkUpdateBox, checkUpdateBtn)
useSysPlaylistBtn := container.NewHBox(
widget.NewLabel(i18n.T("gui.config.basic.use_system_playlist")),
component.NewCheckOneWayBinding(
i18n.T("gui.config.basic.use_system_playlist.prompt"),
&config.General.UseSystemPlaylist,
config.General.UseSystemPlaylist),
)
b.panel = container.NewVBox(randomPlaylist, useSysPlaylistBtn, skipWhenErr, outputDevice, checkUpdateBox, checkUpdateBtn)
return b.panel
}

View File

@@ -79,15 +79,20 @@ func Initialize() {
})
checkUpdate()
MainWindow.SetFixedSize(true)
MainWindow.SetFixedSize(config.General.FixedSize)
if config.General.ShowSystemTray {
setupSysTray()
} else {
MainWindow.SetCloseIntercept(
func() {
// save twice i don;t care
// todo: save twice i don;t care
_ = config.SaveToConfigFile(config.ConfigPath)
MainWindow.Close()
})
}
MainWindow.SetOnClosed(func() {
if playerWindow != nil {
playerWindow.Close()
}
})
}

View File

@@ -65,13 +65,17 @@ func handlePlayNext() {
events.PlaylistNextCmdEvent{
Remove: true,
})
} else {
return
}
if !config.General.UseSystemPlaylist {
// do not play system playlist
return
}
log.Infof("Try to play next media in system playlist")
global.EventManager.CallA(events.PlaylistNextCmd(model.PlaylistIDSystem),
events.PlaylistNextCmdEvent{
Remove: false,
})
}
})
global.EventManager.RegisterA(

View File

@@ -37,6 +37,6 @@ func Stop() {
//sysmediacontrol.Destroy()
liveroom.StopAndSave()
playlist.Close()
player.StopMpvPlayer()
plugins.ClosePlugins()
player.StopMpvPlayer()
}

View File

@@ -151,7 +151,7 @@ func (p *playlist) Next(delete bool) {
p.Lock.Lock()
if p.Size() == 0 {
// no media in the playlist
// do not issue any event
// do not dispatch any event
p.Lock.Unlock()
return
}

View File

@@ -9,6 +9,8 @@ type _GeneralConfig struct {
AutoCheckUpdate bool
ShowSystemTray bool
PlayNextOnFail bool
UseSystemPlaylist bool
FixedSize bool
}
func (c *_GeneralConfig) Name() string {
@@ -23,4 +25,6 @@ var General = &_GeneralConfig{
Width: 960,
Height: 480,
PlayNextOnFail: false,
UseSystemPlaylist: true,
FixedSize: true,
}