Closed vojislav closed 1 year ago
Hey Vojislav,
Would you be able to provide a stand-alone snippet to reproduce the problem? That would help immensely with debugging. Looking at the source of go-mp3 it looks like it starts reading new mp3 frames when seeking. So it should have the desired position buffered. If the problem lies there, I'm expecting it to be something subtle.
Also have a look at gopxl/beep, the new maintained fork of Beep! If you use the main branch you'll get some other fixes and version upgrades for free. I'll create a tagged version at the beginning of next month. That said, the go-mp3 package that Beep uses is archived but we can try to figure something out to fix this problem.
just to comment, if anyone is having this issue, i managed to fix it by pausing it before calling Seek() like this
func seek(step int) {
seekTo := currentTrack.stream.Position() + step*sr.N(time.Second)
if seekTo < 0 {
seekTo = 0
} else if seekTo >= currentTrack.stream.Len() {
nextTrack()
return
}
wasPaused := playerCtrl.Paused
playerCtrl.Paused = true
currentTrack.stream.Seek(seekTo)
playerCtrl.Paused = wasPaused
}
this is more of a hack, so i'll try with using the gopxl/beep fork and report back. thanks for the suggestion.
This makes me think that this is a concurrency issue. If you're using speaker
, you'll need to Lock()
it before making changes to the streamers it's pulling from (and then Unlock()
after). See the wiki: https://github.com/faiface/beep/wiki/Composing-and-controlling
Good luck with your project!
yeah i tried this and it seems to do the trick as well. thanks!
Calling this function repeatedly causes a crash
I'm pretty sure this had something to do with seeking to a part of the stream before it's buffered, but I'm not sure how to avoid it. I'm guessing there's a check for it or something, but I can't find it. Thanks in advance.
Error message: