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