Skip to content

Commit

Permalink
Merge seekable-queue-load@mahmed2000
Browse files Browse the repository at this point in the history
  • Loading branch information
xxxserxxx committed Dec 23, 2024
2 parents 3359cc5 + b94e70b commit c80c5c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions mpvplayer/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ func (p *Player) IsSongLoaded() (bool, error) {
return !idle, err
}

func (p *Player) IsSeekable() (bool, error) {
seekable, err := p.getPropertyBool("seekable")
return seekable, err
}

func (p *Player) IsPaused() (bool, error) {
pause, err := p.getPropertyBool("pause")
return pause, err
Expand Down
8 changes: 7 additions & 1 deletion page_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,16 @@ func (ui *Ui) createQueuePage() *QueuePage {
if err := ui.player.Play(); err != nil {
queuePage.logger.Printf("error playing: %s", err)
}
_ = ui.player.Pause()
for {
if seekable, err := ui.player.IsSeekable(); err == nil && seekable {
break
}
time.Sleep(100 * time.Millisecond)
}
if err = ui.player.Seek(playQueue.Position); err != nil {
queuePage.logger.Printf("unable to seek to position %s: %s", time.Duration(playQueue.Position)*time.Second, err)
}
_ = ui.player.Pause()
}
}()
case 'i':
Expand Down

0 comments on commit c80c5c0

Please sign in to comment.