Hide subtitles on mute segments
This commit is contained in:
parent
579588a43b
commit
e602bc6097
|
@ -84,33 +84,55 @@ function observePlaybackTime(_, current_pos)
|
||||||
mp.set_property_number("playback-time", segment.segment[2])
|
mp.set_property_number("playback-time", segment.segment[2])
|
||||||
current_pos = segment.segment[2]
|
current_pos = segment.segment[2]
|
||||||
elseif segment.actionType == "mute" then
|
elseif segment.actionType == "mute" then
|
||||||
local muted = mp.get_property_bool("ao-mute") or mp.get_property_bool("mute")
|
-- if ao-mute or mute is false, then it's not muted, which causes it to be muted
|
||||||
if muted ~= true and (video_data.muted_due_to_segment == nil
|
local caused_mute = (mp.get_property_bool("ao-mute") or mp.get_property_bool("mute")) == false
|
||||||
or segment.segment[1] ~= video_data.muted_due_to_segment[1]
|
-- if subs are visible, they'll be hidden
|
||||||
or segment.segment[2] ~= video_data.muted_due_to_segment[2]) then
|
local caused_hidden_subs = mp.get_property_bool("sub-visibility") == true
|
||||||
|
if (caused_mute or caused_hidden_subs) and (video_data.current_mute_segment == nil
|
||||||
|
or segment.segment[1] ~= video_data.current_mute_segment.segment[1]
|
||||||
|
or segment.segment[2] ~= video_data.current_mute_segment.segment[2]) then
|
||||||
mp.osd_message("[sponsorblock] Muting " .. segment.segment[2] - current_pos
|
mp.osd_message("[sponsorblock] Muting " .. segment.segment[2] - current_pos
|
||||||
.. "s " .. category_name)
|
.. "s " .. category_name)
|
||||||
video_data.muted_due_to_segment = segment.segment
|
video_data.current_mute_segment = {
|
||||||
|
segment = segment.segment,
|
||||||
|
caused_mute = caused_mute,
|
||||||
|
caused_hidden_subs = caused_hidden_subs
|
||||||
|
}
|
||||||
|
if caused_mute then
|
||||||
mp.set_property_bool("mute", true)
|
mp.set_property_bool("mute", true)
|
||||||
end
|
end
|
||||||
|
if caused_hidden_subs then
|
||||||
|
mp.set_property_bool("sub-visibility", false)
|
||||||
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
mp.msg.warn("Unknown action type:", segment.actionType)
|
mp.msg.warn("Unknown action type:", segment.actionType)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if video_data.muted_due_to_segment ~= nil and
|
if video_data.current_mute_segment ~= nil and
|
||||||
(current_pos < video_data.muted_due_to_segment[1] or
|
(current_pos < video_data.current_mute_segment.segment[1] or
|
||||||
video_data.muted_due_to_segment[2] <= current_pos) then
|
video_data.current_mute_segment.segment[2] <= current_pos) then
|
||||||
|
if video_data.current_mute_segment.caused_mute then
|
||||||
mp.set_property_bool("mute", false)
|
mp.set_property_bool("mute", false)
|
||||||
video_data.muted_due_to_segment = nil
|
end
|
||||||
|
if video_data.current_mute_segment.caused_hidden_subs then
|
||||||
|
mp.set_property_bool("sub-visibility", true)
|
||||||
|
end
|
||||||
|
video_data.current_mute_segment = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function endFile()
|
function endFile()
|
||||||
if video_data ~= nil and video_data.muted_due_to_segment ~= nil then
|
if video_data ~= nil and video_data.current_mute_segment ~= nil then
|
||||||
|
if video_data.current_mute_segment.caused_mute then
|
||||||
mp.set_property_bool("mute", false)
|
mp.set_property_bool("mute", false)
|
||||||
end
|
end
|
||||||
|
if video_data.current_mute_segment.caused_hidden_subs then
|
||||||
|
mp.set_property_bool("sub-visibility", true)
|
||||||
|
end
|
||||||
|
end
|
||||||
video_data = nil
|
video_data = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -121,9 +143,14 @@ function toggleSponsorblock()
|
||||||
message = message .. "Enabled"
|
message = message .. "Enabled"
|
||||||
else
|
else
|
||||||
disabled = true
|
disabled = true
|
||||||
if video_data ~= nil and video_data.muted_due_to_segment ~= nil then
|
if video_data ~= nil and video_data.current_mute_segment ~= nil then
|
||||||
|
if video_data.current_mute_segment.caused_mute then
|
||||||
mp.set_property_bool("mute", false)
|
mp.set_property_bool("mute", false)
|
||||||
video_data.muted_due_to_segment = nil
|
end
|
||||||
|
if video_data.current_mute_segment.caused_hidden_subs then
|
||||||
|
mp.set_property_bool("sub-visibility", true)
|
||||||
|
end
|
||||||
|
video_data.current_mute_segment = nil
|
||||||
end
|
end
|
||||||
message = message .. "Disabled"
|
message = message .. "Disabled"
|
||||||
end
|
end
|
||||||
|
@ -193,7 +220,6 @@ function getSegments(video_id)
|
||||||
|
|
||||||
for _, i in pairs(segments) do
|
for _, i in pairs(segments) do
|
||||||
if i.videoID == video_id then
|
if i.videoID == video_id then
|
||||||
i.muted_due_to_segment = nil
|
|
||||||
return i
|
return i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue