mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-02 18:22:42 -08:00
fix(plugin): keep loading OSD visible during startup gate
This commit is contained in:
@@ -70,8 +70,17 @@ function M.create(ctx)
|
|||||||
state.auto_play_ready_timeout = nil
|
state.auto_play_ready_timeout = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function clear_auto_play_ready_osd_timer()
|
||||||
|
local timer = state.auto_play_ready_osd_timer
|
||||||
|
if timer and timer.kill then
|
||||||
|
timer:kill()
|
||||||
|
end
|
||||||
|
state.auto_play_ready_osd_timer = nil
|
||||||
|
end
|
||||||
|
|
||||||
local function disarm_auto_play_ready_gate()
|
local function disarm_auto_play_ready_gate()
|
||||||
clear_auto_play_ready_timeout()
|
clear_auto_play_ready_timeout()
|
||||||
|
clear_auto_play_ready_osd_timer()
|
||||||
state.auto_play_ready_gate_armed = false
|
state.auto_play_ready_gate_armed = false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -88,10 +97,18 @@ function M.create(ctx)
|
|||||||
local function arm_auto_play_ready_gate()
|
local function arm_auto_play_ready_gate()
|
||||||
if state.auto_play_ready_gate_armed then
|
if state.auto_play_ready_gate_armed then
|
||||||
clear_auto_play_ready_timeout()
|
clear_auto_play_ready_timeout()
|
||||||
|
clear_auto_play_ready_osd_timer()
|
||||||
end
|
end
|
||||||
state.auto_play_ready_gate_armed = true
|
state.auto_play_ready_gate_armed = true
|
||||||
mp.set_property_native("pause", true)
|
mp.set_property_native("pause", true)
|
||||||
show_osd("Loading subtitle annotations...")
|
show_osd("Loading subtitle annotations...")
|
||||||
|
if type(mp.add_periodic_timer) == "function" then
|
||||||
|
state.auto_play_ready_osd_timer = mp.add_periodic_timer(2.5, function()
|
||||||
|
if state.auto_play_ready_gate_armed then
|
||||||
|
show_osd("Loading subtitle annotations...")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
subminer_log("info", "process", "Pausing playback until SubMiner overlay/tokenization readiness signal")
|
subminer_log("info", "process", "Pausing playback until SubMiner overlay/tokenization readiness signal")
|
||||||
state.auto_play_ready_timeout = mp.add_timeout(AUTO_PLAY_READY_TIMEOUT_SECONDS, function()
|
state.auto_play_ready_timeout = mp.add_timeout(AUTO_PLAY_READY_TIMEOUT_SECONDS, function()
|
||||||
if not state.auto_play_ready_gate_armed then
|
if not state.auto_play_ready_gate_armed then
|
||||||
@@ -287,7 +304,7 @@ function M.create(ctx)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
if attempt == 1 then
|
if attempt == 1 and not state.auto_play_ready_gate_armed then
|
||||||
show_osd("Starting...")
|
show_osd("Starting...")
|
||||||
end
|
end
|
||||||
state.overlay_running = true
|
state.overlay_running = true
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ function M.new()
|
|||||||
},
|
},
|
||||||
auto_play_ready_gate_armed = false,
|
auto_play_ready_gate_armed = false,
|
||||||
auto_play_ready_timeout = nil,
|
auto_play_ready_timeout = nil,
|
||||||
|
auto_play_ready_osd_timer = nil,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ local function run_plugin_scenario(config)
|
|||||||
osd = {},
|
osd = {},
|
||||||
logs = {},
|
logs = {},
|
||||||
property_sets = {},
|
property_sets = {},
|
||||||
|
periodic_timers = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
local function make_mp_stub()
|
local function make_mp_stub()
|
||||||
@@ -90,10 +91,32 @@ local function run_plugin_scenario(config)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function mp.add_timeout(_seconds, callback)
|
function mp.add_timeout(seconds, callback)
|
||||||
if callback then
|
local timeout = {
|
||||||
|
killed = false,
|
||||||
|
}
|
||||||
|
function timeout:kill()
|
||||||
|
self.killed = true
|
||||||
|
end
|
||||||
|
|
||||||
|
local delay = tonumber(seconds) or 0
|
||||||
|
if callback and delay < 5 then
|
||||||
callback()
|
callback()
|
||||||
end
|
end
|
||||||
|
return timeout
|
||||||
|
end
|
||||||
|
|
||||||
|
function mp.add_periodic_timer(seconds, callback)
|
||||||
|
local timer = {
|
||||||
|
seconds = seconds,
|
||||||
|
killed = false,
|
||||||
|
callback = callback,
|
||||||
|
}
|
||||||
|
function timer:kill()
|
||||||
|
self.killed = true
|
||||||
|
end
|
||||||
|
recorded.periodic_timers[#recorded.periodic_timers + 1] = timer
|
||||||
|
return timer
|
||||||
end
|
end
|
||||||
|
|
||||||
function mp.register_script_message(name, fn)
|
function mp.register_script_message(name, fn)
|
||||||
@@ -531,10 +554,22 @@ do
|
|||||||
has_osd_message(recorded.osd, "SubMiner: Loading subtitle annotations..."),
|
has_osd_message(recorded.osd, "SubMiner: Loading subtitle annotations..."),
|
||||||
"pause-until-ready auto-start should show loading OSD message"
|
"pause-until-ready auto-start should show loading OSD message"
|
||||||
)
|
)
|
||||||
|
assert_true(
|
||||||
|
not has_osd_message(recorded.osd, "SubMiner: Starting..."),
|
||||||
|
"pause-until-ready auto-start should avoid replacing loading OSD with generic starting OSD"
|
||||||
|
)
|
||||||
assert_true(
|
assert_true(
|
||||||
has_osd_message(recorded.osd, "SubMiner: Subtitle annotations loaded"),
|
has_osd_message(recorded.osd, "SubMiner: Subtitle annotations loaded"),
|
||||||
"autoplay-ready should show loaded OSD message"
|
"autoplay-ready should show loaded OSD message"
|
||||||
)
|
)
|
||||||
|
assert_true(
|
||||||
|
#recorded.periodic_timers == 1,
|
||||||
|
"pause-until-ready auto-start should create periodic loading OSD refresher"
|
||||||
|
)
|
||||||
|
assert_true(
|
||||||
|
recorded.periodic_timers[1].killed == true,
|
||||||
|
"autoplay-ready should stop periodic loading OSD refresher"
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|||||||
Reference in New Issue
Block a user