SponsorBlock job
This commit is contained in:
1 parent
115b457241
commit
9f5efb0ba7
4 files changed
+35
-31
No files matched your search
@@ -21,30 +21,31 @@ namespace SponsorBlock
|
||||
return
|
||||
end if
|
||||
|
||||
if m.sponsorBlockTask <> invalid
|
||||
m.sponsorBlockTask.cancel = true
|
||||
if m.sponsorBlockSegmentsJob <> invalid
|
||||
m.sponsorBlockSegmentsJob.cancel = true
|
||||
end if
|
||||
|
||||
m.sponsorBlockTask = AsyncTask.Start(Tasks.SponsorBlockTask, {
|
||||
metadata: metadata
|
||||
input = {
|
||||
videoId: metadata.videoId
|
||||
lengthSeconds: metadata.lengthSeconds
|
||||
showNotifications: m.preferences["sponsorblock.show_notifications"]
|
||||
categories: m.preferences["sponsorblock.categories"]
|
||||
}, OnSponsorBlockTaskResults)
|
||||
}
|
||||
|
||||
m.sponsorBlockSegmentsJob = JobSystem.CreateCallback(OnSponsorBlockSegmentsJobDone)
|
||||
JobSystem.QueueJob(m.jobQueue, Jobs.SponsorBlockSegmentsJob, input, m.sponsorBlockSegmentsJob)
|
||||
end function
|
||||
|
||||
function OnSponsorBlockTaskResults(output as object) as void
|
||||
m.sponsorBlockTask = invalid
|
||||
if output.cancelled or m.onCloseCalled = true
|
||||
function OnSponsorBlockSegmentsJobDone(event as object) as void
|
||||
JobSystem.UnobserveCallback(event.getRoSGNode())
|
||||
m.sponsorBlockSegmentsJob = invalid
|
||||
|
||||
info = event.getInfo()
|
||||
if not info.success
|
||||
return
|
||||
end if
|
||||
|
||||
if not output.success
|
||||
error = ErrorUtils.Format(output.error)
|
||||
LogError(error)
|
||||
return
|
||||
end if
|
||||
|
||||
skipSegments = output.result.skipSegments
|
||||
skipSegments = info.data.skipSegments
|
||||
if skipSegments = invalid or skipSegments.Count() = 0
|
||||
return
|
||||
end if
|
||||
@@ -52,7 +53,7 @@ namespace SponsorBlock
|
||||
m.skipSegments = skipSegments
|
||||
m.top.seekMode = "accurate"
|
||||
|
||||
barPath = output.result.barPath
|
||||
barPath = info.data.barPath
|
||||
if barPath <> invalid
|
||||
m.top.trickPlayBar.trackImageUri = barPath
|
||||
m.top.trickPlayBar.filledBarBlendColor = "#FF000080"
|
||||
|
||||
@@ -40,7 +40,7 @@ function Init()
|
||||
|
||||
' Checks if current RokuOS version has showUI field in Video node
|
||||
m.showUIEnabled = m.top.hasField("showUI")
|
||||
LogInfo(`Custom OK handler is ${m.showUIEnabled ? "enabled" : "disabled"}`)
|
||||
LogDebug(`Custom OK handler is ${m.showUIEnabled ? "enabled" : "disabled"}`)
|
||||
|
||||
' asyncStopSemantics available since Roku OS 12.5
|
||||
' It is set to true because stopping synchronously causes timeout and crash
|
||||
@@ -381,9 +381,9 @@ function OnClose()
|
||||
m.videoContentTask.cancel = true
|
||||
m.videoContentTask = invalid
|
||||
end if
|
||||
if m.sponsorBlockTask <> invalid
|
||||
m.sponsorBlockTask.cancel = true
|
||||
m.sponsorBlockTask = invalid
|
||||
if m.sponsorBlockSegmentsJob <> invalid
|
||||
m.sponsorBlockSegmentsJob.cancel = true
|
||||
m.sponsorBlockSegmentsJob = invalid
|
||||
end if
|
||||
|
||||
parent = m.top.getParent()
|
||||
@@ -538,7 +538,7 @@ function HandleOKPress() as boolean
|
||||
state = m.top.state
|
||||
uiVisible = m.top.trickPlaybar.visible
|
||||
isLive = IsLiveVideo()
|
||||
LogInfo(`Handling OK button: state = ${state}, uiVisible = ${uiVisible} isLive = ${isLive}`)
|
||||
LogDebug(`Handling OK button: state = ${state}, uiVisible = ${uiVisible} isLive = ${isLive}`)
|
||||
if state = "playing"
|
||||
if not uiVisible
|
||||
' Video is playing and UI is not visible, show it
|
||||
|
||||
Reference in new issue
Block a user