possible fix for random stop playing

This commit is contained in:
tramhao 2021-02-16 01:32:05 +08:00
parent 23fa8c036f
commit 5bcfa1df7a
2 changed files with 14 additions and 7 deletions

View File

@ -386,7 +386,7 @@ func (c Command) defineCommands() {
if err != nil {
logError(err)
}
gomu.playingBar._progress = position - 1
gomu.playingBar._progress = position
}
}
})
@ -399,7 +399,7 @@ func (c Command) defineCommands() {
if err != nil {
logError(err)
}
gomu.playingBar._progress = position - 1
gomu.playingBar._progress = position
} else {
err := gomu.player.seek(0)
if err != nil {
@ -418,7 +418,7 @@ func (c Command) defineCommands() {
if err != nil {
logError(err)
}
gomu.playingBar._progress = position - 1
gomu.playingBar._progress = position
}
}
})
@ -431,7 +431,7 @@ func (c Command) defineCommands() {
if err != nil {
logError(err)
}
gomu.playingBar._progress = position - 1
gomu.playingBar._progress = position
} else {
err := gomu.player.seek(0)
if err != nil {

View File

@ -151,6 +151,7 @@ next:
p.position = 0
p.isRunning = false
p.format = nil
// p.hasInit = false
gomu.playingBar.stop()
nextSong, err := gomu.queue.dequeue()
@ -178,15 +179,21 @@ next:
}
p.i++
if p.i >= gomu.playingBar.full {
done <- struct{}{}
continue
// break next
}
gomu.playingBar.progress <- 1
speaker.Lock()
p.position = p.getPosition()
speaker.Unlock()
if p.i > gomu.playingBar.full {
/* if p.i > gomu.playingBar.full {
break next
}
} */
}
@ -305,7 +312,7 @@ func (p *Player) seek(pos int) error {
speaker.Lock()
defer speaker.Unlock()
err := p.streamSeekCloser.Seek(pos * int(p.format.SampleRate))
p.i = pos - 1
p.i = pos
return err
}