mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-08 21:37:58 -05:00
Update Progressbar if playlist is paid
This commit is contained in:
15
ui/app.go
15
ui/app.go
@@ -9,11 +9,12 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ImgX int
|
||||
ImgY int
|
||||
ImgW int
|
||||
ImgH int
|
||||
Ui *Application
|
||||
ImgX int
|
||||
ImgY int
|
||||
ImgW int
|
||||
ImgH int
|
||||
start = true
|
||||
Ui *Application
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -87,7 +88,7 @@ func NewApplication() *Application {
|
||||
Root.AfterContextClose(func() { App.SetFocus(Main.Table) })
|
||||
playlistNav.Table.SetBackgroundColor(tcell.ColorDefault)
|
||||
PlaylistActions = map[string]*Action{
|
||||
"playEntry": NewAction(playlistNav.PlaySelectEntry, nil),
|
||||
"playEntry": NewAction(playlistNav.PlaySelectEntry, pBar),
|
||||
"openEntry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
|
||||
r, _ := playlistNav.Table.GetSelection()
|
||||
playlistView.SetPlaylist(&(*playlistNav.Playlists)[r])
|
||||
@@ -150,7 +151,7 @@ func NewApplication() *Application {
|
||||
for {
|
||||
_ImgX, _ImgY, _ImgW, _ImgH := Ui.CoverArt.GetInnerRect()
|
||||
if start {
|
||||
coverArt.RefreshState()
|
||||
RefreshProgress()
|
||||
start = false
|
||||
}
|
||||
if _ImgX != ImgX || _ImgY != ImgY ||
|
||||
|
||||
@@ -12,10 +12,6 @@ import (
|
||||
"gitlab.com/diamondburned/ueberzug-go"
|
||||
)
|
||||
|
||||
var (
|
||||
start = true
|
||||
)
|
||||
|
||||
type CoverArt struct {
|
||||
*tview.Box
|
||||
image *ueberzug.Image
|
||||
|
||||
@@ -75,6 +75,9 @@ func (self *ProgressBar) Draw(screen tcell.Screen) {
|
||||
self.BarText),
|
||||
x, y+2, _width-OFFSET, tview.AlignRight, tcell.ColorWhite)
|
||||
}
|
||||
func (self *ProgressBar) RefreshState() {
|
||||
RefreshProgress()
|
||||
}
|
||||
|
||||
func RefreshProgress() {
|
||||
s, err := spt.GetPlayerState()
|
||||
@@ -86,15 +89,16 @@ func RefreshProgress() {
|
||||
state = s
|
||||
stateLock.Unlock()
|
||||
if Ui != nil && Ui.CoverArt != nil {
|
||||
if s.Item != nil && s.Item.ID != ctrackId {
|
||||
ctrackId = s.Item.ID
|
||||
Ui.CoverArt.RefreshState()
|
||||
if s.Item != nil && state.Item.ID != ctrackId {
|
||||
ctrackId = state.Item.ID
|
||||
go func() {
|
||||
Ui.CoverArt.RefreshState()
|
||||
}()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func RefreshProgressLocal() {
|
||||
stateLock.Lock()
|
||||
if state != nil {
|
||||
if state.Item != nil && state.Playing {
|
||||
if state.Item.Duration-state.Progress >= 1000 {
|
||||
@@ -107,7 +111,6 @@ func RefreshProgressLocal() {
|
||||
}
|
||||
}
|
||||
}
|
||||
stateLock.Unlock()
|
||||
}
|
||||
|
||||
func updateRoutine() {
|
||||
|
||||
Reference in New Issue
Block a user