Refactor to reduce chance of execution timeout
This commit is contained in:
1 parent
ed2ec9bea5
commit
9baa132ca3
1 file changed
+12
-12
@@ -141,37 +141,37 @@ end function
|
|||||||
|
|
||||||
function OnVideoPlayerStateChange() as void
|
function OnVideoPlayerStateChange() as void
|
||||||
state = m.top.state
|
state = m.top.state
|
||||||
|
content = m.top.content
|
||||||
' If we successfully played the video, then any error that comes later is not due to a 403 (FORBIDDEN).
|
' If we successfully played the video, then any error that comes later is not due to a 403 (FORBIDDEN).
|
||||||
' This is to reduce false positives, as we do not want retry another link if the first link is working fine.
|
' This is to reduce false positives, as we do not want retry another link if the first link is working fine.
|
||||||
if state = "playing" and not m.videoPlayingSuccess
|
if state = "playing" and not m.videoPlayingSuccess
|
||||||
LogInfo(`Now playing video ${m.top.content.url}`)
|
LogInfo(`Now playing video ${content.url}`)
|
||||||
m.videoPlayingSuccess = true
|
m.videoPlayingSuccess = true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if state = "error"
|
if state = "error"
|
||||||
errorInfo = m.top.errorInfo
|
errorInfo = m.top.errorInfo
|
||||||
LogError(`Error playing video ${m.top.content.videoId}`, errorInfo)
|
LogError(`Error playing video ${content.videoId}`, errorInfo)
|
||||||
if m.videoPlayingSuccess <> true
|
if m.videoPlayingSuccess <> true
|
||||||
' http for stream format, mediaerror for DASH
|
' http for stream format, mediaerror for DASH
|
||||||
if errorInfo.category = "http" or errorInfo.category = "mediaerror"
|
if errorInfo.category = "http" or errorInfo.category = "mediaerror"
|
||||||
currentUrl = m.top.content.url
|
currentUrl = content.url
|
||||||
playletStreamUrls = m.top.content.playletStreamUrls
|
playletStreamUrls = content.playletStreamUrls
|
||||||
playletStreamUrlIndex = m.top.content.playletStreamUrlIndex
|
playletStreamUrlIndex = content.playletStreamUrlIndex
|
||||||
playletStreamUrlIndex++
|
playletStreamUrlIndex++
|
||||||
m.top.content.playletStreamUrlIndex = playletStreamUrlIndex
|
content.playletStreamUrlIndex = playletStreamUrlIndex
|
||||||
if playletStreamUrlIndex < playletStreamUrls.Count()
|
if playletStreamUrlIndex < playletStreamUrls.Count()
|
||||||
nextUrl = playletStreamUrls[playletStreamUrlIndex]
|
nextUrl = playletStreamUrls[playletStreamUrlIndex]
|
||||||
LogError(`Stream ${currentUrl} failed to play. Trying next stream ${nextUrl}`)
|
LogError(`Stream ${currentUrl} failed to play. Trying next stream ${nextUrl}`)
|
||||||
|
|
||||||
m.top.content.url = nextUrl
|
content.url = nextUrl
|
||||||
' This video errored, and is about to finish, so don't close the video yet
|
' This video errored, and is about to finish, so don't close the video yet
|
||||||
' That's why we should ignore the next "finished" event
|
' That's why we should ignore the next "finished" event
|
||||||
m.ignoreNextFinishedState = true
|
m.ignoreNextFinishedState = true
|
||||||
m.top.control = "play"
|
m.top.control = "play"
|
||||||
|
|
||||||
if ValidInt(m.top.content.timestamp) > 0
|
if ValidInt(content.timestamp) > 0
|
||||||
m.top.seek = m.top.content.timestamp
|
m.top.seek = content.timestamp
|
||||||
end if
|
end if
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
@@ -185,7 +185,7 @@ function OnVideoPlayerStateChange() as void
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
if state = "finished"
|
if state = "finished"
|
||||||
metadata = m.top.content?.metadata
|
metadata = content?.metadata
|
||||||
if not PlayNext(metadata?.recommendedVideos)
|
if not PlayNext(metadata?.recommendedVideos)
|
||||||
m.container@.watchedVideosClear(invalid)
|
m.container@.watchedVideosClear(invalid)
|
||||||
VideoUtils.CloseVideo()
|
VideoUtils.CloseVideo()
|
||||||
@@ -205,7 +205,7 @@ function OnVideoPlayerStateChange() as void
|
|||||||
end for
|
end for
|
||||||
end if
|
end if
|
||||||
|
|
||||||
title = `Error playing video ${m.top.content.videoId}`
|
title = `Error playing video ${content.videoId}`
|
||||||
LogError(title, messageLines)
|
LogError(title, messageLines)
|
||||||
DialogUtils.ShowDialog(messageLines, title, true)
|
DialogUtils.ShowDialog(messageLines, title, true)
|
||||||
' TODO:P1 play next video in the queue after showing the error dialog
|
' TODO:P1 play next video in the queue after showing the error dialog
|
||||||
|
|||||||
Reference in new issue
Block a user