Inconsistent behavior for fileplayer getOffset, setOffset, and getLength

I'm really confused on what the expected behavior is for these methods. I am running the SDK Version 2.7.5 (187685) on MacOS. I'm new to dev on Playdate, so maybe I'm misunderstanding something fundamental? But my bug-senses are tingling, because I feel like I'm building on shifting sands in re to the fileplayer's internal state.

I included the whole codebase I'm working in, and I created a branch to demonstrate the issues I'm having by using all of these methods (Uhhhh sorry let me know if there is a problem linking to GitHub or YouTube. I just hosted the issue in these places because they're most familiar for people):

https://github.com/bpevs/nolook/blob/fileplayer-bug/source/Modules/playback.lua#L54-L60

https://www.youtube.com/watch?v=b-Ots_zi0Q8

The video has no sound, but it does still show the inconsistent values of getOffset and getLength. I'll try to recreate with sound a little later to show the inconsistency of setOffset. But basically, audio always plays on first load, but then only sometimes plays, sometimes starts from the beginning when given a direct value from getOffset, and then definitely doesn't play at the end of the video where the length has a value of 0.04.

Also, audio never starts if I run:

player:stop()
player:setOffset(0)
player:play()

Am I missing something important about using fileplayer and if things need to be in a particular state to get some sort of expected playback experience with setOffset? If I'm not using the finish callback, does stop do something more than just pause + reset offset to 0?

Duplicate of my bug report: Fileplayer getOffset() reports wrong value sometimes

EDIT: Also, the reason that you can't post links is that mods need to manually approve you to be allowed to post them.

1 Like

Ah oops I didn't see that one; thanks for bringing it up. Let's add future conversation to that thread instead of here.