mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2026-03-15 14:03:17 +08:00
add headless mode
This commit is contained in:
4
Makefile
4
Makefile
@@ -19,10 +19,10 @@ endif
|
|||||||
|
|
||||||
bundle:
|
bundle:
|
||||||
fyne bundle --name resImageIcon --package resource ./assets/icon.png > ./resource/bundle.go
|
fyne bundle --name resImageIcon --package resource ./assets/icon.png > ./resource/bundle.go
|
||||||
# fyne bundle --append --name resFontMSYaHei --package resource ./assets/msyh.ttc >> ./resource/bundle.go
|
|
||||||
# fyne bundle --append --name resFontMSYaHeiBold --package resource ./assets/msyhbd.ttc >> ./resource/bundle.go
|
|
||||||
fyne bundle --append --name resFontMSYaHei --package resource ./assets/msyh0.ttf >> ./resource/bundle.go
|
fyne bundle --append --name resFontMSYaHei --package resource ./assets/msyh0.ttf >> ./resource/bundle.go
|
||||||
fyne bundle --append --name resFontMSYaHeiBold --package resource ./assets/msyhbd0.ttf >> ./resource/bundle.go
|
fyne bundle --append --name resFontMSYaHeiBold --package resource ./assets/msyhbd0.ttf >> ./resource/bundle.go
|
||||||
|
# fyne bundle --append --name resFontMSYaHei --package resource ./assets/msyh.ttc >> ./resource/bundle.go
|
||||||
|
# fyne bundle --append --name resFontMSYaHeiBold --package resource ./assets/msyhbd.ttc >> ./resource/bundle.go
|
||||||
|
|
||||||
prebuild: bundle
|
prebuild: bundle
|
||||||
$(RRM) ./release
|
$(RRM) ./release
|
||||||
|
|||||||
20
app/main.go
20
app/main.go
@@ -11,10 +11,13 @@ import (
|
|||||||
"AynaLivePlayer/pkg/logger"
|
"AynaLivePlayer/pkg/logger"
|
||||||
loggerRepo "AynaLivePlayer/pkg/logger/repository"
|
loggerRepo "AynaLivePlayer/pkg/logger/repository"
|
||||||
"flag"
|
"flag"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var dev = flag.Bool("dev", false, "dev")
|
var dev = flag.Bool("dev", false, "dev")
|
||||||
|
var headless = flag.Bool("headless", false, "headless")
|
||||||
|
|
||||||
type _LogConfig struct {
|
type _LogConfig struct {
|
||||||
config.BaseConfig
|
config.BaseConfig
|
||||||
@@ -50,14 +53,20 @@ func main() {
|
|||||||
global.Logger.Info("================Program Start================")
|
global.Logger.Info("================Program Start================")
|
||||||
global.Logger.Infof("================Current Version: %s================", model.Version(config.Version))
|
global.Logger.Infof("================Current Version: %s================", model.Version(config.Version))
|
||||||
internal.Initialize()
|
internal.Initialize()
|
||||||
gui.Initialize()
|
|
||||||
go func() {
|
go func() {
|
||||||
// temporary fix for gui not render correctly.
|
// temporary fix for gui not render correctly.
|
||||||
// wait until gui rendered then start event dispatching
|
// wait until gui rendered then start event dispatching
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
global.EventManager.Start()
|
global.EventManager.Start()
|
||||||
}()
|
}()
|
||||||
gui.MainWindow.ShowAndRun()
|
if *headless || config.Experimental.Headless {
|
||||||
|
quit := make(chan os.Signal)
|
||||||
|
signal.Notify(quit, os.Interrupt)
|
||||||
|
<-quit
|
||||||
|
} else {
|
||||||
|
gui.Initialize()
|
||||||
|
gui.MainWindow.ShowAndRun()
|
||||||
|
}
|
||||||
global.Logger.Info("closing internal server")
|
global.Logger.Info("closing internal server")
|
||||||
internal.Stop()
|
internal.Stop()
|
||||||
global.Logger.Infof("closing event manager")
|
global.Logger.Infof("closing event manager")
|
||||||
@@ -66,6 +75,11 @@ func main() {
|
|||||||
global.Logger.Infof("saving translation")
|
global.Logger.Infof("saving translation")
|
||||||
i18n.SaveTranslation()
|
i18n.SaveTranslation()
|
||||||
}
|
}
|
||||||
_ = config.SaveToConfigFile(config.ConfigPath)
|
err := config.SaveToConfigFile(config.ConfigPath)
|
||||||
|
if err != nil {
|
||||||
|
global.Logger.Errorf("save config failed: %v", err)
|
||||||
|
} else {
|
||||||
|
global.Logger.Infof("save config success")
|
||||||
|
}
|
||||||
global.Logger.Info("================Program End================")
|
global.Logger.Info("================Program End================")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ func GetAssetPath(name string) string {
|
|||||||
return path.Join(AssetsPath, name)
|
return path.Join(AssetsPath, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
var DEFAULT_CONFIGS = []Config{General}
|
var DEFAULT_CONFIGS = []Config{General, Experimental}
|
||||||
|
|
||||||
type Config interface {
|
type Config interface {
|
||||||
Name() string
|
Name() string
|
||||||
|
|||||||
14
pkg/config/config_experimental.go
Normal file
14
pkg/config/config_experimental.go
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
type _ExperimentalConfig struct {
|
||||||
|
BaseConfig
|
||||||
|
Headless bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *_ExperimentalConfig) Name() string {
|
||||||
|
return "Experimental"
|
||||||
|
}
|
||||||
|
|
||||||
|
var Experimental = &_ExperimentalConfig{
|
||||||
|
Headless: false,
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ type _GeneralConfig struct {
|
|||||||
UseSystemPlaylist bool
|
UseSystemPlaylist bool
|
||||||
FixedSize bool
|
FixedSize bool
|
||||||
EnableSMC bool // enable system media control
|
EnableSMC bool // enable system media control
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *_GeneralConfig) Name() string {
|
func (c *_GeneralConfig) Name() string {
|
||||||
|
|||||||
Reference in New Issue
Block a user