From 3f5cb84696aa940b9dbf08edb5db0c91cb0fa2c9 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Fri, 25 Nov 2022 14:34:21 -0500 Subject: [PATCH] Sponsorblock add mute sections --- src/components/VideoPlayer/Video.bs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/components/VideoPlayer/Video.bs b/src/components/VideoPlayer/Video.bs index b7d322f0..f01b71e7 100644 --- a/src/components/VideoPlayer/Video.bs +++ b/src/components/VideoPlayer/Video.bs @@ -196,6 +196,8 @@ function SetCaptions(metadata as object, videoPlayer as object, contentNode as o end function function OnPositionChangeSkipSponsorBlockSections() as void + shouldMute = false + muteCategory = "" segments = m.videoPlayer.skipSegments for each segment in segments ' TODO: handle other action types @@ -211,5 +213,20 @@ function OnPositionChangeSkipSponsorBlockSections() as void return end if end if + if segment["actionType"] = "mute" + segmentRange = segment["segment"] + segmentStart = segmentRange[0] + segmentEnd = segmentRange[1] + currentPosition = m.videoPlayer.position + if (segmentStart < currentPosition) and (segmentEnd > currentPosition) + shouldMute = true + muteCategory = segment["category"] + exit for + end if + end if end for + if m.videoPlayer.mute <> shouldMute + print(`Muting section: ${muteCategory} - ${shouldMute}`) + m.videoPlayer.mute = shouldMute + end if end function