[skip ci] tweak sponsorblock notification timing
This commit is contained in:
1 parent
c2b6b75f94
commit
7ab98024c1
1 file changed
+8
-9
@@ -99,7 +99,7 @@ namespace SponsorBlock
|
|||||||
|
|
||||||
function UpdateSponsorBlockChapter(time as double) as void
|
function UpdateSponsorBlockChapter(time as double) as void
|
||||||
segments = m.skipSegments
|
segments = m.skipSegments
|
||||||
segment = FindSegmentByTime(segments, time, 0)
|
segment = FindSegmentByTime(segments, time)
|
||||||
if segment = invalid
|
if segment = invalid
|
||||||
m.top.chapter = ""
|
m.top.chapter = ""
|
||||||
return
|
return
|
||||||
@@ -107,7 +107,7 @@ namespace SponsorBlock
|
|||||||
m.top.chapter = segment.title
|
m.top.chapter = segment.title
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function FindSegmentByTime(segments as object, time as dynamic, endOffset as integer) as dynamic
|
function FindSegmentByTime(segments as object, time as dynamic) as dynamic
|
||||||
' Binary search for the segment that contains the time.
|
' Binary search for the segment that contains the time.
|
||||||
' This search sometimes fails if the segments overlap.
|
' This search sometimes fails if the segments overlap.
|
||||||
' For most cases, this is acceptable, since it is not common for segments to overlap.
|
' For most cases, this is acceptable, since it is not common for segments to overlap.
|
||||||
@@ -118,7 +118,7 @@ namespace SponsorBlock
|
|||||||
segment = segments[middle]
|
segment = segments[middle]
|
||||||
if time < segment.start
|
if time < segment.start
|
||||||
high = middle - 1
|
high = middle - 1
|
||||||
else if time > (segment.end + endOffset)
|
else if time > segment.end
|
||||||
low = middle + 1
|
low = middle + 1
|
||||||
else
|
else
|
||||||
return segment
|
return segment
|
||||||
@@ -131,18 +131,17 @@ namespace SponsorBlock
|
|||||||
segments = m.skipSegments
|
segments = m.skipSegments
|
||||||
position = m.top.position
|
position = m.top.position
|
||||||
|
|
||||||
' We add a small offset to the end position of the segment.
|
segment = FindSegmentByTime(segments, position)
|
||||||
' This is so that when we skip a segment, we don't get
|
|
||||||
' another notification to skip it.
|
|
||||||
' Seeking accuracy is not perfect, so we need to account for that.
|
|
||||||
segment = FindSegmentByTime(segments, position, -1)
|
|
||||||
if segment = invalid
|
if segment = invalid
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
action = segment.option
|
action = segment.option
|
||||||
|
|
||||||
if segment.showNotification
|
' If we're close to the end of the segment, we don't want to show
|
||||||
|
' a notification, since it is possible this is where we skipped to.
|
||||||
|
' Seeking is not super accurate.
|
||||||
|
if segment.showNotification and Abs(segment.end - position) >= 1
|
||||||
SponsorBlock.ShowNotifcation(m.notifications, segment, action)
|
SponsorBlock.ShowNotifcation(m.notifications, segment, action)
|
||||||
|
|
||||||
if action = SegmentAction.ManualSkip
|
if action = SegmentAction.ManualSkip
|
||||||
|
|||||||
Reference in new issue
Block a user