diff --git a/mpvplayer/player.go b/mpvplayer/player.go index a13d104..c6ac7d7 100644 --- a/mpvplayer/player.go +++ b/mpvplayer/player.go @@ -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 diff --git a/page_queue.go b/page_queue.go index c3bdbfc..c766742 100644 --- a/page_queue.go +++ b/page_queue.go @@ -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':