Skip to content

Commit d8fcff5

Browse files
authored
Check and fix if video_duration is nil
`video_duration` could be `nil` in certain streaming scenarios where the duration is unknown ahead of time, e.g., real-time streaming with RTSP streams. If unchecked for a nil value, `video_duration` will lead to the following error otherwise: ``` [SimpleHistory] [C]: ? [SimpleHistory] [C]: ? [SimpleHistory] Lua error: /Users/name/.config/mpv/scripts/SimpleHistory.lua:2131: attempt to perform arithmetic on local 'video_duration' (a nil value) ```
1 parent 5ad3701 commit d8fcff5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

scripts/SimpleHistory.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,6 +2116,11 @@ function history_resume_option()
21162116
local logged_time = 0
21172117
local percentage = 0
21182118
local video_duration = mp.get_property_number('duration')
2119+
if video_duration and video_duration ~= nil then
2120+
video_duration = tonumber(video_duration)
2121+
else
2122+
video_duration = 0
2123+
end
21192124
list_contents = read_log_table()
21202125
if not list_contents or not list_contents[1] then return end
21212126
for i = #list_contents, 1, -1 do

0 commit comments

Comments
 (0)