Playdate.sound.fileplayer getLength() / getOffset() returns incorrect values

With SDK 1.12.0, getLength() / getOffset() now return the correct values. Thanks for the fix!
However, there is a new problem that when setOffset is called, the value of getLength() is incorrect.

local gfx = playdate.graphics
gfx.setColor(gfx.kColorBlack)

local _sndPlayer = nil
local _status = "Playing ..."

_sndPlayer = playdate.sound.fileplayer.new("sounds/Test.mp3")
_sndPlayer:play()
_sndPlayer:setFinishCallback(function () _status = "Finished!" end)

function playdate.AButtonDown()
    local offset = _sndPlayer:getOffset()
    offset += 1
    if offset < _sndPlayer:getLength() then
        _sndPlayer:setOffset(offset)
    end
end

function playdate.update()
    gfx.clear()
    gfx.drawText(_status , 50, 40)
    gfx.drawText("Offset: " .. _sndPlayer:getOffset() , 50, 80)
    gfx.drawText("Length: " .. _sndPlayer:getLength() , 50, 120)
end

TestSetOffset.zip (7.1 MB)

In my test program, when I press the AButton, I advance the Offset by 1, but each time I press the AButton, the value of getLength changes.

1 Like