mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2025-12-06 10:22:50 +08:00
try move start after gui initialized
This commit is contained in:
10
app/main.go
10
app/main.go
@@ -17,7 +17,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var dev = flag.Bool("dev", false, "dev")
|
var dev = flag.Bool("dev", false, "dev")
|
||||||
@@ -68,19 +67,14 @@ 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()
|
||||||
go func() {
|
|
||||||
// temporary fix for gui not render correctly.
|
|
||||||
// wait until gui rendered then start event dispatching
|
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
//global.EventManager.Start()
|
|
||||||
_ = global.EventBus.Start()
|
|
||||||
}()
|
|
||||||
if *headless || config.Experimental.Headless {
|
if *headless || config.Experimental.Headless {
|
||||||
quit := make(chan os.Signal)
|
quit := make(chan os.Signal)
|
||||||
signal.Notify(quit, os.Interrupt)
|
signal.Notify(quit, os.Interrupt)
|
||||||
|
_ = global.EventBus.Start()
|
||||||
<-quit
|
<-quit
|
||||||
} else {
|
} else {
|
||||||
gui.Initialize()
|
gui.Initialize()
|
||||||
|
_ = global.EventBus.Start()
|
||||||
gctx.Context.Window.ShowAndRun()
|
gctx.Context.Window.ShowAndRun()
|
||||||
}
|
}
|
||||||
global.Logger.Info("closing internal server")
|
global.Logger.Info("closing internal server")
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const ReplyMiaosicGetMediaInfo = "reply.miaosic.getMediaInfo"
|
|||||||
|
|
||||||
type ReplyMiaosicGetMediaInfoData struct {
|
type ReplyMiaosicGetMediaInfoData struct {
|
||||||
Info miaosic.MediaInfo `json:"info"`
|
Info miaosic.MediaInfo `json:"info"`
|
||||||
Error error
|
Error error `json:"error"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const CmdMiaosicGetMediaUrl = "cmd.miaosic.getMediaUrl"
|
const CmdMiaosicGetMediaUrl = "cmd.miaosic.getMediaUrl"
|
||||||
@@ -26,5 +26,31 @@ const ReplyMiaosicGetMediaUrl = "reply.miaosic.getMediaUrl"
|
|||||||
|
|
||||||
type ReplyMiaosicGetMediaUrlData struct {
|
type ReplyMiaosicGetMediaUrlData struct {
|
||||||
Urls []miaosic.MediaUrl `json:"urls"`
|
Urls []miaosic.MediaUrl `json:"urls"`
|
||||||
Error error
|
Error error `json:"error"`
|
||||||
|
}
|
||||||
|
|
||||||
|
const CmdMiaosicQrLogin = "cmd.miaosic.qrLogin"
|
||||||
|
|
||||||
|
type CmdMiaosicQrLoginData struct {
|
||||||
|
Provider string `json:"provider"`
|
||||||
|
}
|
||||||
|
|
||||||
|
const ReplyMiaosicQrLogin = "reply.miaosic.qrLogin"
|
||||||
|
|
||||||
|
type ReplyMiaosicQrLoginData struct {
|
||||||
|
Session miaosic.QrLoginSession `json:"session"`
|
||||||
|
Error error `json:"error"`
|
||||||
|
}
|
||||||
|
|
||||||
|
const CmdMiaosicQrLoginVerify = "cmd.miaosic.qrLoginVerify"
|
||||||
|
|
||||||
|
type CmdMiaosicQrLoginVerifyData struct {
|
||||||
|
Session miaosic.QrLoginSession `json:"session"`
|
||||||
|
}
|
||||||
|
|
||||||
|
const ReplyMiaosicQrLoginVerify = "reply.miaosic.qrLoginVerify"
|
||||||
|
|
||||||
|
type ReplyMiaosicQrLoginVerifyData struct {
|
||||||
|
Result miaosic.QrLoginResult `json:"result"`
|
||||||
|
Error error `json:"error"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ func Initialize() {
|
|||||||
handleSearch()
|
handleSearch()
|
||||||
handleInfo()
|
handleInfo()
|
||||||
createLyricLoader()
|
createLyricLoader()
|
||||||
|
handleSourceLogin()
|
||||||
|
|
||||||
_ = global.EventBus.Publish(
|
_ = global.EventBus.Publish(
|
||||||
events.MediaProviderUpdate, events.MediaProviderUpdateEvent{
|
events.MediaProviderUpdate, events.MediaProviderUpdateEvent{
|
||||||
|
|||||||
50
internal/source/login.go
Normal file
50
internal/source/login.go
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package source
|
||||||
|
|
||||||
|
import (
|
||||||
|
"AynaLivePlayer/core/events"
|
||||||
|
"AynaLivePlayer/global"
|
||||||
|
"AynaLivePlayer/pkg/eventbus"
|
||||||
|
"github.com/AynaLivePlayer/miaosic"
|
||||||
|
)
|
||||||
|
|
||||||
|
func handleSourceLogin() {
|
||||||
|
err := global.EventBus.Subscribe("",
|
||||||
|
events.CmdMiaosicQrLogin, "internal.media_provider.qrlogin_handler", func(event *eventbus.Event) {
|
||||||
|
data := event.Data.(events.CmdMiaosicQrLoginData)
|
||||||
|
log.Infof("trying login %s", data.Provider)
|
||||||
|
pvdr, ok := miaosic.GetProvider(data.Provider)
|
||||||
|
if !ok {
|
||||||
|
_ = global.EventBus.Reply(
|
||||||
|
event, events.ReplyMiaosicQrLogin,
|
||||||
|
events.ReplyMiaosicQrLoginData{
|
||||||
|
Session: miaosic.QrLoginSession{},
|
||||||
|
Error: miaosic.ErrorNoSuchProvider,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
result, ok := pvdr.(miaosic.Loginable)
|
||||||
|
if !ok {
|
||||||
|
_ = global.EventBus.Reply(
|
||||||
|
event, events.ReplyMiaosicQrLogin,
|
||||||
|
events.ReplyMiaosicQrLoginData{
|
||||||
|
Session: miaosic.QrLoginSession{},
|
||||||
|
Error: miaosic.ErrNotImplemented,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var session miaosic.QrLoginSession
|
||||||
|
sess, err := result.QrLogin()
|
||||||
|
if err == nil && sess != nil {
|
||||||
|
session = *sess
|
||||||
|
}
|
||||||
|
_ = global.EventBus.Reply(
|
||||||
|
event, events.ReplyMiaosicQrLogin,
|
||||||
|
events.ReplyMiaosicQrLoginData{
|
||||||
|
Session: session,
|
||||||
|
Error: err,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorW("Subscribe search event failed", "error", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -76,6 +76,7 @@ func (w *SourceLogin) Description() string {
|
|||||||
return i18n.T("plugin.sourcelogin.description")
|
return i18n.T("plugin.sourcelogin.description")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: fix using fyne async update ui
|
||||||
func (w *SourceLogin) CreatePanel() fyne.CanvasObject {
|
func (w *SourceLogin) CreatePanel() fyne.CanvasObject {
|
||||||
if w.panel != nil {
|
if w.panel != nil {
|
||||||
return w.panel
|
return w.panel
|
||||||
|
|||||||
Reference in New Issue
Block a user