fix: chapter remaining time scaled by speed even when destination_time is set to time-remaining

This commit is contained in:
tomasklaen
2024-03-13 11:01:12 +01:00
parent 581adf4c5b
commit 6fa34c31d0
3 changed files with 7 additions and 6 deletions

View File

@@ -258,7 +258,7 @@ function Timeline:render()
local offset = opts.size / (visibility > 0 and 24 or 28)
for _, range in ipairs(state.uncached_ranges) do
if not buffered_playtime and (range[1] > state.time or range[2] > state.time) then
buffered_playtime = (range[1] - state.time) / (state.speed or 1)
buffered_playtime = (range[1] - state.time) / state.speed
end
if options.timeline_cache then
local ax = range[1] < 0.5 and bax or math.floor(t2x(range[1]))

View File

@@ -294,7 +294,8 @@ function TopBar:render()
local text = '' .. state.current_chapter.index .. ': ' .. state.current_chapter.title
local next_chapter = state.chapters[state.current_chapter.index + 1]
local chapter_end = next_chapter and next_chapter.time or state.duration or 0
local remaining_time = ((state.time and state.time or 0) - chapter_end) / (state.speed or 1)
local remaining_time = ((state.time or 0) - chapter_end) /
(options.destination_time == 'time-remaining' and 1 or state.speed)
local remaining_human = format_time(remaining_time, math.abs(remaining_time))
local opts = {
size = font_size,

View File

@@ -430,13 +430,13 @@ function update_fullormaxed()
end
function update_human_times()
state.speed = state.speed or 1
if state.time then
local max_seconds = state.duration
if state.duration then
local speed = state.speed or 1
if options.destination_time == 'playtime-remaining' then
max_seconds = speed >= 1 and state.duration or state.duration / speed
state.destination_time_human = format_time((state.time - state.duration) / speed, max_seconds)
max_seconds = state.speed >= 1 and state.duration or state.duration / state.speed
state.destination_time_human = format_time((state.time - state.duration) / state.speed, max_seconds)
elseif options.destination_time == 'total' then
state.destination_time_human = format_time(state.duration, max_seconds)
else
@@ -447,7 +447,7 @@ function update_human_times()
end
state.time_human = format_time(state.time, max_seconds)
else
state.time_human = nil
state.time_human, state.destination_time_human = nil, nil
end
end