mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2026-06-02 09:35:48 +08:00
fix text output
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,7 +3,7 @@ assets/webinfo/*.html
|
||||
assets/webinfo/assets
|
||||
resource/bundle.go
|
||||
music
|
||||
textinfo
|
||||
/txtinfo/
|
||||
CMakeCache.txt
|
||||
/config/
|
||||
/release/
|
||||
1
go.mod
1
go.mod
@@ -12,6 +12,7 @@ require (
|
||||
fyne.io/x/fyne v0.0.0-20240326131024-3ba9170cc3be
|
||||
github.com/AynaLivePlayer/liveroom-sdk v0.1.0
|
||||
github.com/AynaLivePlayer/miaosic v0.1.5
|
||||
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b
|
||||
github.com/antonfisher/nested-logrus-formatter v1.3.1
|
||||
github.com/aynakeya/go-mpv v0.0.6
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240306074159-ea2d69986ecb
|
||||
|
||||
26
go.sum
26
go.sum
@@ -37,18 +37,26 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
|
||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
fyne.io/fyne/v2 v2.4.4 h1:4efSRpoikcGbqQN83yzC9WmF8UNq9olsaJQ/Ejme6Z8=
|
||||
fyne.io/fyne/v2 v2.4.4/go.mod h1:VyrxAOZ3NRZRWBvNIJbfqoKOG4DdbewoPk7ozqJKNPY=
|
||||
fyne.io/fyne/v2 v2.4.5 h1:W6jpAEmLoBbKyBB+EXqI7GMJ7kLgHQWCa0wZHUV2VfQ=
|
||||
fyne.io/fyne/v2 v2.4.5/go.mod h1:SlOgbca0y80cRObu/JOhxIJdIgtoW7aCyqUVlTMgs0Y=
|
||||
fyne.io/systray v1.10.1-0.20231115130155-104f5ef7839e h1:Hvs+kW2VwCzNToF3FmnIAzmivNgrclwPgoUdVSrjkP8=
|
||||
fyne.io/systray v1.10.1-0.20231115130155-104f5ef7839e/go.mod h1:oM2AQqGJ1AMo4nNqZFYU8xYygSBZkW2hmdJ7n4yjedE=
|
||||
fyne.io/x/fyne v0.0.0-20240326131024-3ba9170cc3be h1:HBAwKsmfTO4r1Ndlksy5oXIxgWiazj0gu2qmhOmkRFU=
|
||||
fyne.io/x/fyne v0.0.0-20240326131024-3ba9170cc3be/go.mod h1:1pa3ZVIopRWNvfSG4ZrSkcZ3mJ8qoHPZv4PT8/zpn1o=
|
||||
github.com/AynaLivePlayer/blivedm-go v0.0.0-20240408074929-6565ab41764b h1:dzZ0gfHxB/mKVW5gBprK46XVFKIwk9ohL2nfuCq3XoI=
|
||||
github.com/AynaLivePlayer/blivedm-go v0.0.0-20240408074929-6565ab41764b/go.mod h1:wg2vP2yIJNPJKnmFWLi8WwrRL5w3/xl8gHdzYPdesMg=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/PuerkitoBio/goquery v1.7.1 h1:oE+T06D+1T7LNrn91B4aERsRIeCLJ/oPSa6xB9FPnz4=
|
||||
github.com/PuerkitoBio/goquery v1.7.1/go.mod h1:XY0pP4kfraEmmV1O7Uf6XyjoslwsneBbgeDjLYuN8xY=
|
||||
github.com/XiaoMengXinX/Music163Api-Go v0.1.30 h1:MqRItDFtX1J0JTlFtwN2RwjsYMA7/g/+cTjcOJXy19s=
|
||||
github.com/XiaoMengXinX/Music163Api-Go v0.1.30/go.mod h1:kLU/CkLxKnEJFCge0URvQ0lHt6ImoG1/2aVeNbgV2RQ=
|
||||
github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY=
|
||||
github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk=
|
||||
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b h1:slYM766cy2nI3BwyRiyQj/Ud48djTMtMebDqepE95rw=
|
||||
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b/go.mod h1:1KcenG0jGWcpt8ov532z81sp/kMMUG485J2InIOyADM=
|
||||
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
|
||||
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||
github.com/andybalholm/cascadia v1.2.0 h1:vuRCkM5Ozh/BfmsaTm26kbjm0mIOM3yS5Ek/F5h18aE=
|
||||
github.com/andybalholm/cascadia v1.2.0/go.mod h1:YCyR8vOZT9aZ1CHEd8ap0gMVm2aFgxBp0T0eFw1RUQY=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
@@ -108,15 +116,15 @@ github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20211213063430-748e38ca8aec/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b h1:GgabKamyOYguHqHjSkDACcgoPIz3w0Dis/zJ1wyHHHU=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240306074159-ea2d69986ecb h1:S9I8pIVT5JHKDvmI1vQ0qs5fqxzUfhcZm/YbUC/8k1k=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240306074159-ea2d69986ecb/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY=
|
||||
github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I=
|
||||
github.com/go-text/render v0.0.0-20230619120952-35bccb6164b8 h1:VkKnvzbvHqgEfm351rfr8Uclu5fnwq8HP2ximUzJsBM=
|
||||
github.com/go-text/render v0.0.0-20230619120952-35bccb6164b8/go.mod h1:h29xCucjNsDcYb7+0rJokxVwYAq+9kQ19WiFuBKkYtc=
|
||||
github.com/go-text/render v0.1.0 h1:osrmVDZNHuP1RSu3pNG7Z77Sd2xSbcb/xWytAj9kyVs=
|
||||
github.com/go-text/render v0.1.0/go.mod h1:jqEuNMenrmj6QRnkdpeaP0oKGFLDNhDkVKwGjsWWYU4=
|
||||
github.com/go-text/typesetting v0.1.0 h1:vioSaLPYcHwPEPLT7gsjCGDCoYSbljxoHJzMnKwVvHw=
|
||||
github.com/go-text/typesetting v0.1.0/go.mod h1:d22AnmeKq/on0HNv73UFriMKc4Ez6EqZAofLhAzpSzI=
|
||||
github.com/go-text/typesetting-utils v0.0.0-20231211103740-d9332ae51f04 h1:zBx+p/W2aQYtNuyZNcTfinWvXBQwYtDfme051PR/lAY=
|
||||
github.com/go-text/typesetting-utils v0.0.0-20240329101916-eee87fb235a3 h1:levTnuLLUmpavLGbJYLJA7fQnKeS7P1eCdAlM+vReXk=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
|
||||
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
@@ -523,6 +531,7 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
@@ -705,6 +714,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
@@ -729,6 +740,7 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"AynaLivePlayer/plugin/diange"
|
||||
"AynaLivePlayer/plugin/qiege"
|
||||
"AynaLivePlayer/plugin/sourcelogin"
|
||||
"AynaLivePlayer/plugin/textinfo"
|
||||
)
|
||||
|
||||
func Initialize() {
|
||||
@@ -19,7 +20,10 @@ func Initialize() {
|
||||
controller.Initialize()
|
||||
liveroom.Initialize()
|
||||
plugins.Initialize()
|
||||
plugins.LoadPlugins(diange.NewDiange(), qiege.NewQiege(), sourcelogin.NewSourceLogin())
|
||||
plugins.LoadPlugins(
|
||||
diange.NewDiange(), qiege.NewQiege(), sourcelogin.NewSourceLogin(),
|
||||
textinfo.NewTextInfo(),
|
||||
)
|
||||
}
|
||||
|
||||
func Stop() {
|
||||
|
||||
@@ -11,8 +11,8 @@ func main() {
|
||||
a := app.New()
|
||||
w := a.NewWindow("SysTray")
|
||||
|
||||
//icon, _ := fyne.LoadResourceFromPath("./assets/icon.jpg")
|
||||
icon, _ := fyne.LoadResourceFromPath("./assets/icon.png")
|
||||
icon, _ := fyne.LoadResourceFromPath("./assets/icon.jpg")
|
||||
//icon, _ := fyne.LoadResourceFromPath("./assets/icon.png")
|
||||
|
||||
if desk, ok := a.(desktop.App); ok {
|
||||
m := fyne.NewMenu("MyApp",
|
||||
|
||||
54
plugin/textinfo/model.go
Normal file
54
plugin/textinfo/model.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package textinfo
|
||||
|
||||
import (
|
||||
"AynaLivePlayer/core/model"
|
||||
"github.com/AynaLivePlayer/miaosic"
|
||||
)
|
||||
|
||||
type Time struct {
|
||||
Seconds int
|
||||
Minutes int
|
||||
TotalSeconds int
|
||||
}
|
||||
|
||||
func NewTimeFromSec(sec int) Time {
|
||||
return Time{
|
||||
Seconds: sec % 60,
|
||||
Minutes: sec / 60,
|
||||
TotalSeconds: sec,
|
||||
}
|
||||
}
|
||||
|
||||
type MediaInfo struct {
|
||||
Index int
|
||||
Title string
|
||||
Artist string
|
||||
Album string
|
||||
Username string
|
||||
Cover miaosic.Picture
|
||||
}
|
||||
|
||||
func NewMediaInfo(idx int, media model.Media) MediaInfo {
|
||||
return MediaInfo{
|
||||
Index: idx,
|
||||
Title: media.Info.Title,
|
||||
Artist: media.Info.Artist,
|
||||
Album: media.Info.Album,
|
||||
Username: media.ToUser().Name,
|
||||
Cover: media.Info.Cover,
|
||||
}
|
||||
}
|
||||
|
||||
type OutInfo struct {
|
||||
// ============== Current ==============
|
||||
Current MediaInfo
|
||||
CurrentTime Time
|
||||
TotalTime Time
|
||||
|
||||
Lyric string
|
||||
NextLyrics []string
|
||||
|
||||
// ============== Playlist ==============
|
||||
Playlist []MediaInfo
|
||||
PlaylistLength int
|
||||
}
|
||||
@@ -1,17 +1,20 @@
|
||||
package textinfo
|
||||
|
||||
import (
|
||||
"AynaLivePlayer/core/adapter"
|
||||
"AynaLivePlayer/core/events"
|
||||
"AynaLivePlayer/core/model"
|
||||
"AynaLivePlayer/global"
|
||||
"AynaLivePlayer/gui"
|
||||
"AynaLivePlayer/gui/component"
|
||||
"AynaLivePlayer/pkg/config"
|
||||
"AynaLivePlayer/pkg/event"
|
||||
"AynaLivePlayer/pkg/i18n"
|
||||
"AynaLivePlayer/pkg/logger"
|
||||
"bytes"
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/ajstarks/svgo"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@@ -30,24 +33,6 @@ type Template struct {
|
||||
Tmpl *template.Template
|
||||
}
|
||||
|
||||
type MediaInfo struct {
|
||||
Index int
|
||||
Title string
|
||||
Artist string
|
||||
Album string
|
||||
Username string
|
||||
Cover model.Picture
|
||||
}
|
||||
|
||||
type OutInfo struct {
|
||||
Current MediaInfo
|
||||
CurrentTime int
|
||||
TotalTime int
|
||||
Lyric string
|
||||
Playlist []MediaInfo
|
||||
PlaylistCount int
|
||||
}
|
||||
|
||||
type TextInfo struct {
|
||||
config.BaseConfig
|
||||
Rendering bool
|
||||
@@ -55,13 +40,19 @@ type TextInfo struct {
|
||||
templates []*Template
|
||||
emptyCover []byte
|
||||
panel fyne.CanvasObject
|
||||
ctr adapter.IControlBridge
|
||||
log adapter.ILogger
|
||||
log logger.ILogger
|
||||
}
|
||||
|
||||
func NewTextInfo(ctr adapter.IControlBridge) *TextInfo {
|
||||
b, _ := ioutil.ReadFile(config.GetAssetPath("empty.png"))
|
||||
return &TextInfo{Rendering: true, emptyCover: b, ctr: ctr, log: ctr.Logger().WithModule(MODULE_PLUGIN_TEXTINFO)}
|
||||
func NewTextInfo() *TextInfo {
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
canvas := svg.New(buf)
|
||||
canvas.Start(256, 256)
|
||||
canvas.Image(0, 0, 256, 256, "cover.jpg")
|
||||
canvas.End()
|
||||
return &TextInfo{Rendering: true,
|
||||
emptyCover: buf.Bytes(),
|
||||
log: global.Logger.WithPrefix(MODULE_PLUGIN_TEXTINFO),
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TextInfo) Title() string {
|
||||
@@ -171,14 +162,14 @@ func (t *TextInfo) OutputCover() {
|
||||
return
|
||||
}
|
||||
if !t.info.Current.Cover.Exists() {
|
||||
err := ioutil.WriteFile(filepath.Join(Out_Path, "cover.jpg"), t.emptyCover, 0666)
|
||||
err := os.WriteFile(filepath.Join(Out_Path, "cover.jpg"), t.emptyCover, 0666)
|
||||
if err != nil {
|
||||
t.log.Warnf("write cover file failed: %s", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if t.info.Current.Cover.Data != nil {
|
||||
err := ioutil.WriteFile(filepath.Join(Out_Path, "cover.jpg"), t.info.Current.Cover.Data, 0666)
|
||||
err := os.WriteFile(filepath.Join(Out_Path, "cover.jpg"), t.info.Current.Cover.Data, 0666)
|
||||
if err != nil {
|
||||
t.log.Warnf("write cover file failed: %s", err)
|
||||
}
|
||||
@@ -191,7 +182,7 @@ func (t *TextInfo) OutputCover() {
|
||||
t.log.Warnf("get cover %s content failed: %s", t.info.Current.Cover.Url, err)
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(Out_Path, "cover.jpg"), resp.Body(), 0666)
|
||||
err = os.WriteFile(filepath.Join(Out_Path, "cover.jpg"), resp.Body(), 0666)
|
||||
if err != nil {
|
||||
t.log.Warnf("write cover file failed: %s", err)
|
||||
}
|
||||
@@ -199,66 +190,52 @@ func (t *TextInfo) OutputCover() {
|
||||
}
|
||||
|
||||
func (t *TextInfo) registerHandlers() {
|
||||
t.ctr.PlayControl().EventManager().RegisterA(events.EventPlay, "plugin.textinfo.current", func(event *event.Event) {
|
||||
t.info.Current = MediaInfo{
|
||||
Index: 0,
|
||||
Title: event.Data.(events.PlayEvent).Media.Title,
|
||||
Artist: event.Data.(events.PlayEvent).Media.Artist,
|
||||
Album: event.Data.(events.PlayEvent).Media.Album,
|
||||
Cover: event.Data.(events.PlayEvent).Media.Cover,
|
||||
Username: event.Data.(events.PlayEvent).Media.ToUser().Name,
|
||||
}
|
||||
t.RenderTemplates()
|
||||
t.OutputCover()
|
||||
})
|
||||
if t.ctr.PlayControl().GetPlayer().ObserveProperty(
|
||||
model.PlayerPropTimePos, "plugin.txtinfo.timepos", func(event *event.Event) {
|
||||
data := event.Data.(events.PlayerPropertyUpdateEvent).Value
|
||||
if data == nil {
|
||||
t.info.CurrentTime = 0
|
||||
return
|
||||
global.EventManager.RegisterA(
|
||||
events.PlayerPlayingUpdate, "plugin.textinfo.playing", func(event *event.Event) {
|
||||
data := event.Data.(events.PlayerPlayingUpdateEvent)
|
||||
if data.Removed {
|
||||
t.info.Current = MediaInfo{}
|
||||
} else {
|
||||
t.info.Current = NewMediaInfo(0, data.Media)
|
||||
}
|
||||
ct := int(data.(float64))
|
||||
if ct == t.info.CurrentTime {
|
||||
return
|
||||
}
|
||||
t.info.CurrentTime = ct
|
||||
t.RenderTemplates()
|
||||
}) != nil {
|
||||
t.log.Error("register time-pos handler failed")
|
||||
}
|
||||
if t.ctr.PlayControl().GetPlayer().ObserveProperty(
|
||||
model.PlayerPropDuration, "plugin.txtinfo.duration", func(event *event.Event) {
|
||||
data := event.Data.(events.PlayerPropertyUpdateEvent).Value
|
||||
if data == nil {
|
||||
t.info.TotalTime = 0
|
||||
t.OutputCover()
|
||||
})
|
||||
global.EventManager.RegisterA(
|
||||
events.PlayerPropertyTimePosUpdate, "plugin.txtinfo.timepos", func(event *event.Event) {
|
||||
data := event.Data.(events.PlayerPropertyTimePosUpdateEvent).TimePos
|
||||
ct := int(data)
|
||||
if ct == t.info.CurrentTime.TotalSeconds {
|
||||
return
|
||||
}
|
||||
t.info.TotalTime = int(data.(float64))
|
||||
t.RenderTemplates()
|
||||
}) != nil {
|
||||
t.log.Error("fail to register handler for total time with property duration")
|
||||
}
|
||||
t.ctr.Playlists().GetCurrent().EventManager().RegisterA(
|
||||
events.EventPlaylistUpdate, "plugin.textinfo.playlist", func(event *event.Event) {
|
||||
pl := make([]MediaInfo, 0)
|
||||
e := event.Data.(events.PlaylistUpdateEvent)
|
||||
for index, m := range e.Playlist.Medias {
|
||||
pl = append(pl, MediaInfo{
|
||||
Index: index,
|
||||
Title: m.Title,
|
||||
Artist: m.Artist,
|
||||
Album: m.Album,
|
||||
Username: m.ToUser().Name,
|
||||
})
|
||||
}
|
||||
t.info.Playlist = pl
|
||||
t.info.CurrentTime = NewTimeFromSec(ct)
|
||||
t.RenderTemplates()
|
||||
})
|
||||
t.ctr.PlayControl().GetLyric().EventManager().RegisterA(
|
||||
events.EventLyricUpdate, "plugin.textinfo.lyric", func(event *event.Event) {
|
||||
lrcLine := event.Data.(events.LyricUpdateEvent).Lyric
|
||||
t.info.Lyric = lrcLine.Now.Lyric
|
||||
global.EventManager.RegisterA(
|
||||
events.PlayerPropertyDurationUpdate, "plugin.txtinfo.duration", func(event *event.Event) {
|
||||
data := event.Data.(events.PlayerPropertyDurationUpdateEvent).Duration
|
||||
ct := int(data)
|
||||
if ct == t.info.TotalTime.TotalSeconds {
|
||||
return
|
||||
}
|
||||
t.info.TotalTime = NewTimeFromSec(ct)
|
||||
t.RenderTemplates()
|
||||
})
|
||||
global.EventManager.RegisterA(
|
||||
events.PlaylistDetailUpdate(model.PlaylistIDPlayer), "plugin.textinfo.playlist", func(event *event.Event) {
|
||||
pl := make([]MediaInfo, 0)
|
||||
data := event.Data.(events.PlaylistDetailUpdateEvent)
|
||||
for index, m := range data.Medias {
|
||||
pl = append(pl, NewMediaInfo(index, m))
|
||||
}
|
||||
t.info.Playlist = pl
|
||||
t.info.PlaylistLength = len(pl)
|
||||
t.RenderTemplates()
|
||||
})
|
||||
global.EventManager.RegisterA(
|
||||
events.PlayerLyricPosUpdate, "plugin.textinfo.lyricpos", func(event *event.Event) {
|
||||
data := event.Data.(events.PlayerLyricPosUpdateEvent)
|
||||
t.info.Lyric = data.CurrentLine.Lyric
|
||||
t.RenderTemplates()
|
||||
})
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ var ImageEmptyQrCode = &fyne.StaticResource{
|
||||
StaticName: "flat-color-icons--qr-code.svg",
|
||||
StaticContent: []byte("<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"black\" d=\"M1 1h10v10H1zm2 2v6h6V3z\"/><path fill=\"black\" fill-rule=\"evenodd\" d=\"M5 5h2v2H5z\"/><path fill=\"black\" d=\"M13 1h10v10H13zm2 2v6h6V3z\"/><path fill=\"black\" fill-rule=\"evenodd\" d=\"M17 5h2v2h-2z\"/><path fill=\"black\" d=\"M1 13h10v10H1zm2 2v6h6v-6z\"/><path fill=\"black\" fill-rule=\"evenodd\" d=\"M5 17h2v2H5z\"/><path fill=\"black\" d=\"M23 19h-4v4h-6V13h1h-1v6h2v2h2v-6h-2v-2h-1h3v2h2v2h2v-4h2zm0 2v2h-2v-2z\"/></svg>"),
|
||||
}
|
||||
|
||||
var ImageIcon = resImageIcon
|
||||
var FontMSYaHei = resFontMSYaHei
|
||||
var FontMSYaHeiBold = resFontMSYaHeiBold
|
||||
|
||||
@@ -2,6 +2,6 @@ Title: {{ .Current.Title }}
|
||||
Artist: {{ .Current.Artist }}
|
||||
Album: {{ .Current.Album}}
|
||||
Username: {{ .Current.Username }}
|
||||
Progress(in seconds): {{.CurrentTime}} / {{.TotalTime}}
|
||||
Progress(in minutes:seconds): {{ GetMinutes .CurrentTime}}:{{ GetSeconds .CurrentTime}} / {{ GetMinutes .TotalTime}}:{{ GetSeconds .TotalTime}}
|
||||
Progress(in seconds): {{.CurrentTime.TotalSeconds}} / {{.TotalTime.TotalSeconds}}
|
||||
Progress(in minutes:seconds): {{ .CurrentTime.Minutes}}:{{ .CurrentTime.Seconds}} / {{ .TotalTime.Minutes}}:{{ .TotalTime.Seconds}}
|
||||
Lyric: {{.Lyric}}
|
||||
Reference in New Issue
Block a user