Update Progressbar if playlist is paid

This commit is contained in:
aditya-K2
2023-04-13 08:53:39 +05:30
parent 5c094daa18
commit 32789a1370
3 changed files with 16 additions and 16 deletions

View File

@@ -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 ||

View File

@@ -12,10 +12,6 @@ import (
"gitlab.com/diamondburned/ueberzug-go"
)
var (
start = true
)
type CoverArt struct {
*tview.Box
image *ueberzug.Image

View File

@@ -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() {