fileplayer:setOffset() requires special care regarding the buffer size of the fileplayer

While writing code to scrub through an audio file using the crank, using a fileplayer with a 3 second buffer, I found that if I wanted to move the file on by 0.5 second, I had to get the offset with fileplayer:getOffet(), add 0.5, and also add 3 seconds for the buffer size.

If I did not add 3, then the file would step backwards instead. This was particularly pernicious near the start of the file, where setting an offset less than the buffer size caused the next call to getOffset() to return 24345, and then the player ended.

It isn't mentioned here: Inside Playdate

Is this a bug in the SDK or the documentation, or am I missing something?

1 Like