Fix sponsor skip infinite loop bug (#231)

This commit is contained in:
Brahim Hadriche authored and GitHub committed 2023-12-19 20:02:15 -05:00
1 parent 54b0acbe8f
commit f581d568d9
4 files changed
+42 -21

No files matched your search

@@ -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