mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-12 16:08:52 +01:00
music player can list playlist and library files
This commit is contained in:
parent
2d18c23e89
commit
e59d572610
@ -1,7 +1,7 @@
|
|||||||
package MusicPlayer
|
package MusicPlayer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
//"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
@ -224,9 +224,7 @@ func (self *MusicLibListPage) Click() {
|
|||||||
conn := self.Parent.MpdClient
|
conn := self.Parent.MpdClient
|
||||||
conn.Add(cur_li.Path)
|
conn.Add(cur_li.Path)
|
||||||
self.Parent.SyncList()
|
self.Parent.SyncList()
|
||||||
//addfile(cur_li.Path)
|
fmt.Println("add" , cur_li.Path)
|
||||||
//PlayListPage.SyncList()
|
|
||||||
//print("add" , cur_li._Path)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,13 +235,12 @@ func (self *MusicLibListPage) Click() {
|
|||||||
|
|
||||||
func (self *MusicLibListPage) KeyDown(ev *event.Event) {
|
func (self *MusicLibListPage) KeyDown(ev *event.Event) {
|
||||||
|
|
||||||
if ev.Data["Key"] == UI.CurKeys["Left"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
if UI.IsKeyMenuOrB(ev.Data["Key"]) || ev.Data["Key"] == UI.CurKeys["Left"] {
|
||||||
self.ReturnToUpLevelPage()
|
self.ReturnToUpLevelPage()
|
||||||
self.Screen.Draw()
|
self.Screen.Draw()
|
||||||
self.Screen.SwapAndShow()
|
self.Screen.SwapAndShow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ev.Data["Key"] == UI.CurKeys["Up"] {
|
if ev.Data["Key"] == UI.CurKeys["Up"] {
|
||||||
|
|
||||||
self.ScrollUp()
|
self.ScrollUp()
|
||||||
@ -258,6 +255,9 @@ func (self *MusicLibListPage) KeyDown(ev *event.Event) {
|
|||||||
self.Screen.SwapAndShow()
|
self.Screen.SwapAndShow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if UI.IsKeyStartOrA(ev.Data["Key"]) {
|
||||||
|
self.Click()
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -285,6 +285,9 @@ func (self *MusicLibListPage) Draw() {
|
|||||||
v.Draw()
|
v.Draw()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.Scroller.UpdateSize( len(self.MyList)*UI.DefaultInfoPageListItemHeight, self.PsIndex*UI.DefaultInfoPageListItemHeight)
|
||||||
|
self.Scroller.Draw()
|
||||||
|
|
||||||
} else{
|
} else{
|
||||||
self.Ps.(*ListPageSelector).Width = self.Width
|
self.Ps.(*ListPageSelector).Width = self.Width
|
||||||
self.Ps.Draw()
|
self.Ps.Draw()
|
||||||
|
|||||||
@ -4,6 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"log"
|
"log"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
"github.com/cuu/gogame/event"
|
"github.com/cuu/gogame/event"
|
||||||
"github.com/cuu/gogame/rect"
|
"github.com/cuu/gogame/rect"
|
||||||
"github.com/cuu/gogame/surface"
|
"github.com/cuu/gogame/surface"
|
||||||
@ -36,6 +38,9 @@ type MusicPlayerPage struct {
|
|||||||
Scrolled int
|
Scrolled int
|
||||||
|
|
||||||
MpdClient *mpd.Client
|
MpdClient *mpd.Client
|
||||||
|
|
||||||
|
CurSongTime string
|
||||||
|
CurSongName string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMusicPlayerPage() *MusicPlayerPage {
|
func NewMusicPlayerPage() *MusicPlayerPage {
|
||||||
@ -60,6 +65,8 @@ func NewMusicPlayerPage() *MusicPlayerPage {
|
|||||||
p.BGwidth = 56
|
p.BGwidth = 56
|
||||||
p.BGheight = 70
|
p.BGheight = 70
|
||||||
|
|
||||||
|
p.CurSongTime = "0:0"
|
||||||
|
|
||||||
|
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
@ -76,6 +83,8 @@ func (self *MusicPlayerPage) OnLoadCb() {
|
|||||||
|
|
||||||
fmt.Println("Start mpd client")
|
fmt.Println("Start mpd client")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.SyncList()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *MusicPlayerPage) OnPopUpCb() {
|
func (self *MusicPlayerPage) OnPopUpCb() {
|
||||||
@ -86,6 +95,10 @@ func (self *MusicPlayerPage) OnPopUpCb() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *MusicPlayerPage) OnReturnBackCb() {
|
||||||
|
self.SyncList()
|
||||||
|
}
|
||||||
|
|
||||||
func (self *MusicPlayerPage) SetCoords() {
|
func (self *MusicPlayerPage) SetCoords() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -146,7 +159,29 @@ func (self *MusicPlayerPage) SyncPlaying() {
|
|||||||
}
|
}
|
||||||
current_song,_ := conn.CurrentSong()
|
current_song,_ := conn.CurrentSong()
|
||||||
if len(current_song) > 0 {
|
if len(current_song) > 0 {
|
||||||
|
if val,ok := current_song["song"]; ok{
|
||||||
|
posid, _ := strconv.Atoi(val)
|
||||||
|
if posid < len(self.MyList) {
|
||||||
|
if state,ok2 := current_song["state"]; ok2 {
|
||||||
|
if state == "stop" {
|
||||||
|
self.MyList[posid].(*MusicPlayPageListItem).Active = false
|
||||||
|
}else{
|
||||||
|
self.MyList[posid].(*MusicPlayPageListItem).Active = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if song_time,ok3 := current_song["time"]; ok3 {
|
||||||
|
self.CurSongTime = song_time
|
||||||
|
times := strings.Split(self.CurSongTime,":")
|
||||||
|
if len(times) > 1{
|
||||||
|
cur,_ := strconv.ParseFloat(times[0],64)
|
||||||
|
end,_ := strconv.ParseFloat(times[1],64)
|
||||||
|
pos := int( (cur/end)*100.0 )
|
||||||
|
self.MyList[posid].(*MusicPlayPageListItem).PlayingProcess = pos
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,12 +199,12 @@ func (self *MusicPlayerPage) Init() {
|
|||||||
self.Width = self.Screen.Width
|
self.Width = self.Screen.Width
|
||||||
self.Height = self.Screen.Height
|
self.Height = self.Screen.Height
|
||||||
|
|
||||||
ps := UI.NewInfoPageSelector()
|
//ps := UI.NewInfoPageSelector()
|
||||||
ps.Width = UI.Width - 12
|
ps := NewListPageSelector()
|
||||||
ps.PosX = 2
|
//ps.Width = UI.Width - 12
|
||||||
ps.Parent = self
|
ps.Parent = self
|
||||||
|
|
||||||
self.Ps = ps
|
self.Ps = ps
|
||||||
|
|
||||||
self.PsIndex = 0
|
self.PsIndex = 0
|
||||||
|
|
||||||
bgpng := UI.NewIconItem()
|
bgpng := UI.NewIconItem()
|
||||||
@ -218,6 +253,21 @@ func (self *MusicPlayerPage) KeyDown(ev *event.Event) {
|
|||||||
self.Screen.Draw()
|
self.Screen.Draw()
|
||||||
self.Screen.SwapAndShow()
|
self.Screen.SwapAndShow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ev.Data["Key"] == UI.CurKeys["Up"] {
|
||||||
|
|
||||||
|
self.ScrollUp()
|
||||||
|
self.Screen.Draw()
|
||||||
|
self.Screen.SwapAndShow()
|
||||||
|
}
|
||||||
|
|
||||||
|
if ev.Data["Key"] == UI.CurKeys["Down"] {
|
||||||
|
|
||||||
|
self.ScrollDown()
|
||||||
|
self.Screen.Draw()
|
||||||
|
self.Screen.SwapAndShow()
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,8 +277,42 @@ func (self *MusicPlayerPage) Draw() {
|
|||||||
if len(self.MyList) == 0 {
|
if len(self.MyList) == 0 {
|
||||||
self.Icons["bg"].NewCoord(self.Width/2, self.Height/2)
|
self.Icons["bg"].NewCoord(self.Width/2, self.Height/2)
|
||||||
self.Icons["bg"].Draw()
|
self.Icons["bg"].Draw()
|
||||||
}
|
}else {
|
||||||
|
if len(self.MyList)*UI.DefaultInfoPageListItemHeight > self.Height {
|
||||||
|
self.Ps.(*ListPageSelector).Width = self.Width - 11
|
||||||
|
self.Ps.Draw()
|
||||||
|
|
||||||
|
for _, v := range self.MyList {
|
||||||
|
if v.(*MusicPlayPageListItem).PosY > self.Height+self.Height/2 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.(*MusicPlayPageListItem).PosY < 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
v.Draw()
|
||||||
|
}
|
||||||
|
|
||||||
|
self.Scroller.UpdateSize( len(self.MyList)*UI.DefaultInfoPageListItemHeight, self.PsIndex*UI.DefaultInfoPageListItemHeight)
|
||||||
|
self.Scroller.Draw()
|
||||||
|
|
||||||
|
} else{
|
||||||
|
self.Ps.(*ListPageSelector).Width = self.Width
|
||||||
|
self.Ps.Draw()
|
||||||
|
for _, v := range self.MyList {
|
||||||
|
if v.(*MusicPlayPageListItem).PosY > self.Height+self.Height/2 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.(*MusicPlayPageListItem).PosY < 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
v.Draw()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if self.HWND != nil {
|
if self.HWND != nil {
|
||||||
surface.Fill(self.HWND, UI.MySkinManager.GiveColor("White"))
|
surface.Fill(self.HWND, UI.MySkinManager.GiveColor("White"))
|
||||||
rect_ := rect.Rect(self.PosX, self.PosY, self.Width, self.Height)
|
rect_ := rect.Rect(self.PosX, self.PosY, self.Width, self.Height)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user