Fix sponsor skip infinite loop bug (#231)
This commit is contained in:
1 parent
54b0acbe8f
commit
f581d568d9
4 files changed
+42
-21
No files matched your search
@@ -135,10 +135,23 @@ namespace SponsorBlock
|
||||
end if
|
||||
|
||||
if action = "AutoSkip"
|
||||
m.top.seek = segmentEnd
|
||||
LogInfo("Skipping section:", segment["category"])
|
||||
SendSkippedSectionEvent(segment.UUID)
|
||||
return
|
||||
duration = m.top.duration
|
||||
' Sometimes segmentEnd is greater than duration
|
||||
if duration > 0 and segmentEnd > duration
|
||||
segmentEnd = duration
|
||||
end if
|
||||
' If the segment is at the end of the video, skip the video instead of seeking
|
||||
if duration > 0 and Abs(segmentEnd - duration) < 2
|
||||
LogInfo("Skipping section:", segment["category"], "at end of video")
|
||||
SendSkippedSectionEvent(segment.UUID)
|
||||
OnVideoFinished()
|
||||
return
|
||||
else
|
||||
LogInfo("Skipping section:", segment["category"])
|
||||
SendSkippedSectionEvent(segment.UUID)
|
||||
m.top.seek = segmentEnd
|
||||
return
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
|
||||
@@ -185,23 +185,8 @@ function OnVideoPlayerStateChange() as void
|
||||
end if
|
||||
|
||||
if state = "finished"
|
||||
if content = invalid
|
||||
m.playQueue@.watchedVideosClear()
|
||||
VideoUtils.CloseVideo()
|
||||
return
|
||||
end if
|
||||
|
||||
metadata = content.metadata
|
||||
if metadata = invalid
|
||||
m.playQueue@.watchedVideosClear()
|
||||
VideoUtils.CloseVideo()
|
||||
return
|
||||
end if
|
||||
|
||||
if not PlayNext(metadata.recommendedVideos)
|
||||
m.playQueue@.watchedVideosClear()
|
||||
VideoUtils.CloseVideo()
|
||||
end if
|
||||
OnVideoFinished()
|
||||
return
|
||||
end if
|
||||
|
||||
if state = "error"
|
||||
@@ -225,6 +210,27 @@ function OnVideoPlayerStateChange() as void
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnVideoFinished() as void
|
||||
content = m.top.content
|
||||
if content = invalid
|
||||
m.playQueue@.watchedVideosClear()
|
||||
VideoUtils.CloseVideo()
|
||||
return
|
||||
end if
|
||||
|
||||
metadata = content.metadata
|
||||
if metadata = invalid
|
||||
m.playQueue@.watchedVideosClear()
|
||||
VideoUtils.CloseVideo()
|
||||
return
|
||||
end if
|
||||
|
||||
if not PlayNext(metadata.recommendedVideos)
|
||||
m.playQueue@.watchedVideosClear()
|
||||
VideoUtils.CloseVideo()
|
||||
end if
|
||||
end function
|
||||
|
||||
function PlayNext(recommendedVideos as object) as boolean
|
||||
if m.playQueue@.PlayNextItem()
|
||||
return true
|
||||
|
||||
Reference in new issue
Block a user