video player seek issue
This commit is contained in:
1 parent
aa2acc5eb8
commit
b7fb8614b7
4 files changed
+77
-43
No files matched your search
@@ -13,7 +13,6 @@ import "pkg:/components/VideoPlayerDev/VideoNode.bs"
|
|||||||
import "pkg:/components/VideoQueue/VideoQueueUtils.bs"
|
import "pkg:/components/VideoQueue/VideoQueueUtils.bs"
|
||||||
import "pkg:/source/utils/Locale.bs"
|
import "pkg:/source/utils/Locale.bs"
|
||||||
import "pkg:/source/utils/Logging.bs"
|
import "pkg:/source/utils/Logging.bs"
|
||||||
import "pkg:/source/utils/MathUtils.bs"
|
|
||||||
import "pkg:/source/utils/RemoteKeys.bs"
|
import "pkg:/source/utils/RemoteKeys.bs"
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
import "pkg:/source/utils/Types.bs"
|
import "pkg:/source/utils/Types.bs"
|
||||||
@@ -55,7 +54,6 @@ function Initialize()
|
|||||||
m.watchTimeMarker = -1
|
m.watchTimeMarker = -1
|
||||||
m.reportWatchTime = false
|
m.reportWatchTime = false
|
||||||
m.onCloseCalled = false
|
m.onCloseCalled = false
|
||||||
m.seekToPercent = invalid
|
|
||||||
' a setSeek that arrived while the content loads (ms, -1 = none): the content-load seek goes there instead.
|
' a setSeek that arrived while the content loads (ms, -1 = none): the content-load seek goes there instead.
|
||||||
m.loadingSetSeekMs = -1
|
m.loadingSetSeekMs = -1
|
||||||
|
|
||||||
@@ -869,11 +867,12 @@ function OnVideoError() as void
|
|||||||
LogInfo("error retry -> next stream url=", decision.nextUrl)
|
LogInfo("error retry -> next stream url=", decision.nextUrl)
|
||||||
m.playbackTelemetry.ReportVideoError(errorData, errorInfo, failedUrl, failedUrlIndex, false)
|
m.playbackTelemetry.ReportVideoError(errorData, errorInfo, failedUrl, failedUrlIndex, false)
|
||||||
' the controller already advanced content.url/index; replay it from the initial position (live edge /
|
' the controller already advanced content.url/index; replay it from the initial position (live edge /
|
||||||
' timestamp / percent watched). Swallow the next finished edge.
|
' timestamp / percent watched), seeked before play so it is the start position. Swallow the next
|
||||||
|
' finished edge.
|
||||||
m.ignoreNextFinished = true
|
m.ignoreNextFinished = true
|
||||||
m.repauseAfterSeek = false ' the retry plays fresh; drop any pending re-pause
|
m.repauseAfterSeek = false ' the retry plays fresh; drop any pending re-pause
|
||||||
m.top.control = VideoControl.Play
|
|
||||||
SeekToInitialPosition(content)
|
SeekToInitialPosition(content)
|
||||||
|
m.top.control = VideoControl.Play
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -931,8 +930,6 @@ function OnDuration(event as object) as void
|
|||||||
PushLiveEdge()
|
PushLiveEdge()
|
||||||
end if
|
end if
|
||||||
ApplyTransport()
|
ApplyTransport()
|
||||||
' a percent-of-duration initial seek waits on a known duration.
|
|
||||||
SeekToPercentOfDuration()
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
' Current wall-clock epoch seconds, off the cached roDateTime.
|
' Current wall-clock epoch seconds, off the cached roDateTime.
|
||||||
@@ -1078,7 +1075,6 @@ function OnSetSeek(event as object) as void
|
|||||||
m.loadingSetSeekMs = seekMs
|
m.loadingSetSeekMs = seekMs
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
m.seekToPercent = invalid
|
|
||||||
wasTransport = (m.transport.transportMode <> TransportController.Mode.Idle)
|
wasTransport = (m.transport.transportMode <> TransportController.Mode.Idle)
|
||||||
m.transport.ForceIdleSeek(seekMs, not wasTransport)
|
m.transport.ForceIdleSeek(seekMs, not wasTransport)
|
||||||
ApplyTransport()
|
ApplyTransport()
|
||||||
@@ -1302,31 +1298,22 @@ function SeekToInitialPosition(content as object) as void
|
|||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
percentDurationWatched = ValidFloat(content.percentDurationWatched)
|
percentDurationWatched = ValidFloat(content.percentDurationWatched)
|
||||||
if percentDurationWatched > 0
|
if percentDurationWatched <= 0
|
||||||
m.seekToPercent = percentDurationWatched
|
|
||||||
SeekToPercentOfDuration()
|
|
||||||
end if
|
|
||||||
end function
|
|
||||||
|
|
||||||
function SeekToPercentOfDuration() as void
|
|
||||||
seekToPercent = m.seekToPercent
|
|
||||||
if seekToPercent = invalid
|
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
duration = m.top.duration
|
' the metadata's length, not the Video's duration (known only once playing): a seek into a started DRM play
|
||||||
if duration = 0
|
' errors on some Roku TVs.
|
||||||
return ' OnDuration re-calls this when duration arrives
|
lengthSeconds = ValidInt(ValidAssociativeArray(content.metadata).lengthSeconds)
|
||||||
end if
|
if lengthSeconds <= 0
|
||||||
if duration < 30
|
LogWarn("no lengthSeconds to resume the percent watched from; starting from the beginning. videoId:", content.videoId)
|
||||||
m.seekToPercent = invalid
|
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
m.seekToPercent = invalid
|
if lengthSeconds < 30
|
||||||
seek = (MathUtils.Clamp(seekToPercent, 0, 100) / 100.0) * duration
|
return
|
||||||
if seek > 0
|
|
||||||
LogDebug("seeking to percent watched ->", seek)
|
|
||||||
ApplySeek(Int(seek * 1000))
|
|
||||||
end if
|
end if
|
||||||
|
seekMs = Int(percentDurationWatched / 100.0 * lengthSeconds * 1000)
|
||||||
|
LogDebug("seeking to percent watched ->", seekMs)
|
||||||
|
ApplySeek(seekMs)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function PlayAfterPreviousPlayerHasStopped() as void
|
function PlayAfterPreviousPlayerHasStopped() as void
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ function TestSetup() as void
|
|||||||
|
|
||||||
OnNodeReady()
|
OnNodeReady()
|
||||||
|
|
||||||
|
' after OnNodeReady (the loop above drops it per TestSetup, along with the coordinator's control observer).
|
||||||
|
m.top.seekAtPlay = -1
|
||||||
|
m.top.ObserveField("control", FuncName(OnTestControl))
|
||||||
|
|
||||||
' the children survive across tests too: clear what a previous test's transport or live content left.
|
' the children survive across tests too: clear what a previous test's transport or live content left.
|
||||||
m.transportTimer.control = "none"
|
m.transportTimer.control = "none"
|
||||||
m.trickPlayBar.isLive = false
|
m.trickPlayBar.isLive = false
|
||||||
@@ -98,6 +102,13 @@ function OnTestNudge() as void
|
|||||||
m.top.nudgeCount += 1
|
m.top.nudgeCount += 1
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
' a seek written before control=play is the play's start position; one written after is a seek into the started play.
|
||||||
|
function OnTestControl() as void
|
||||||
|
if m.top.control = VideoControl.Play
|
||||||
|
m.top.seekAtPlay = m.top.seek
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
function OnTestJobRequest(event as object) as void
|
function OnTestJobRequest(event as object) as void
|
||||||
if event.getData().jobName = Jobs.SponsorBlockSegmentViewedJob
|
if event.getData().jobName = Jobs.SponsorBlockSegmentViewedJob
|
||||||
m.top.sponsorViewedCount += 1
|
m.top.sponsorViewedCount += 1
|
||||||
@@ -144,6 +155,16 @@ function TestSeekToInitialPosition(content as object) as void
|
|||||||
SeekToInitialPosition(content)
|
SeekToInitialPosition(content)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
' TestErrorRetry — a stream error before the first frame, with a next stream url to retry: runs the REAL
|
||||||
|
' OnVideoError and returns the seek the device held when the retry wrote control=play.
|
||||||
|
function TestErrorRetry(content as object) as float
|
||||||
|
m.videoPlayedSuccessfully = false ' the seam spec's first-frame setup marked the stream played
|
||||||
|
m.top.content = content
|
||||||
|
m.top.errorInfo = { category: "http", source: "buffer:reader", ignored: false }
|
||||||
|
OnVideoError()
|
||||||
|
return m.top.seekAtPlay
|
||||||
|
end function
|
||||||
|
|
||||||
' TestSetContentLoading — a VideoContentJob in flight (or not), minus the job.
|
' TestSetContentLoading — a VideoContentJob in flight (or not), minus the job.
|
||||||
function TestSetContentLoading(loading as boolean) as void
|
function TestSetContentLoading(loading as boolean) as void
|
||||||
if loading
|
if loading
|
||||||
|
|||||||
@@ -50,6 +50,8 @@
|
|||||||
<field id="nudgeCount" type="integer" />
|
<field id="nudgeCount" type="integer" />
|
||||||
<!-- test-only probe: how many SponsorBlock viewed-segment reports the coordinator queued. -->
|
<!-- test-only probe: how many SponsorBlock viewed-segment reports the coordinator queued. -->
|
||||||
<field id="sponsorViewedCount" type="integer" />
|
<field id="sponsorViewedCount" type="integer" />
|
||||||
|
<!-- test-only probe: the seek the device held when the coordinator last wrote control=play. -->
|
||||||
|
<field id="seekAtPlay" type="float" />
|
||||||
<!-- the Video-only method Initialize calls, plus the spec's drivers (callFunc reaches only interface funcs). -->
|
<!-- the Video-only method Initialize calls, plus the spec's drivers (callFunc reaches only interface funcs). -->
|
||||||
<function name="getHttpAgent" />
|
<function name="getHttpAgent" />
|
||||||
<function name="TestSetup" />
|
<function name="TestSetup" />
|
||||||
@@ -62,6 +64,7 @@
|
|||||||
<function name="TestSetLive" />
|
<function name="TestSetLive" />
|
||||||
<function name="TestSeedSponsorBlock" />
|
<function name="TestSeedSponsorBlock" />
|
||||||
<function name="TestSeekToInitialPosition" />
|
<function name="TestSeekToInitialPosition" />
|
||||||
|
<function name="TestErrorRetry" />
|
||||||
<function name="TestSetContentLoading" />
|
<function name="TestSetContentLoading" />
|
||||||
<function name="TestFireLiveBadgeHold" />
|
<function name="TestFireLiveBadgeHold" />
|
||||||
<function name="TestKillAutoHide" />
|
<function name="TestKillAutoHide" />
|
||||||
|
|||||||
@@ -312,17 +312,6 @@ namespace Tests
|
|||||||
m.assertEqual(Int(m.top.seek * 1000), 42000)
|
m.assertEqual(Int(m.top.seek * 1000), 42000)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@it("setSeek before the duration is known cancels the pending percent-watched seek")
|
|
||||||
function _()
|
|
||||||
m.ArmSeekState("first load")
|
|
||||||
content = CreateObject("roSGNode", "ContentNode")
|
|
||||||
content.AddFields({ percentDurationWatched: 50.0 })
|
|
||||||
m.top.callFunc("TestSeekToInitialPosition", content)
|
|
||||||
m.top.setSeek = 30.5
|
|
||||||
m.top.duration = 600.0
|
|
||||||
m.assertEqual(Int(m.top.seek * 1000), 30500, "the percent seek did not override the setSeek")
|
|
||||||
end function
|
|
||||||
|
|
||||||
@it("setSeek while the content loads becomes the content-load seek, over the resume timestamp")
|
@it("setSeek while the content loads becomes the content-load seek, over the resume timestamp")
|
||||||
function _()
|
function _()
|
||||||
m.top.callFunc("TestSetContentLoading", true)
|
m.top.callFunc("TestSetContentLoading", true)
|
||||||
@@ -357,16 +346,50 @@ namespace Tests
|
|||||||
m.assertEqual(Int(m.top.seek * 1000), 42000)
|
m.assertEqual(Int(m.top.seek * 1000), 42000)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@it("the content-load seek goes to the percent watched once the duration is known")
|
@it("the content-load seek goes to the percent watched of the video's length")
|
||||||
function _()
|
function _()
|
||||||
content = CreateObject("roSGNode", "ContentNode")
|
content = CreateObject("roSGNode", "ContentNode")
|
||||||
content.AddFields({ percentDurationWatched: 25.0 })
|
content.AddFields({ percentDurationWatched: 25.0, metadata: { lengthSeconds: 600 } })
|
||||||
m.top.callFunc("TestSeekToInitialPosition", content)
|
m.top.callFunc("TestSeekToInitialPosition", content)
|
||||||
m.assertEqual(m.top.seek, 0.0, "no seek before the duration is known")
|
|
||||||
m.top.duration = 600.0
|
|
||||||
m.assertEqual(Int(m.top.seek * 1000), 150000)
|
m.assertEqual(Int(m.top.seek * 1000), 150000)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
@it("the content-load seek skips the percent watched when the video's length is unknown")
|
||||||
|
function _()
|
||||||
|
for each metadata in [{}, { lengthSeconds: 0 }]
|
||||||
|
m.top.seek = -1
|
||||||
|
content = CreateObject("roSGNode", "ContentNode")
|
||||||
|
content.AddFields({ percentDurationWatched: 25.0, metadata: metadata })
|
||||||
|
m.top.callFunc("TestSeekToInitialPosition", content)
|
||||||
|
m.top.duration = 600.0
|
||||||
|
m.assertEqual(m.top.seek, -1.0, FormatJson(metadata))
|
||||||
|
end for
|
||||||
|
end function
|
||||||
|
|
||||||
|
@it("the content-load seek skips the percent watched on a video shorter than 30 seconds")
|
||||||
|
function _()
|
||||||
|
m.top.seek = -1
|
||||||
|
content = CreateObject("roSGNode", "ContentNode")
|
||||||
|
content.AddFields({ percentDurationWatched: 50.0, metadata: { lengthSeconds: 29 } })
|
||||||
|
m.top.callFunc("TestSeekToInitialPosition", content)
|
||||||
|
m.assertEqual(m.top.seek, -1.0)
|
||||||
|
end function
|
||||||
|
|
||||||
|
@it("an error retry seeks to the percent watched before it plays")
|
||||||
|
function _()
|
||||||
|
content = CreateObject("roSGNode", "ContentNode")
|
||||||
|
content.AddFields({
|
||||||
|
videoId: "vid1"
|
||||||
|
playletStreamUrls: ["http://a", "http://b"]
|
||||||
|
playletStreamUrlIndex: 0
|
||||||
|
percentDurationWatched: 25.0
|
||||||
|
metadata: { lengthSeconds: 600 }
|
||||||
|
})
|
||||||
|
content.url = "http://a"
|
||||||
|
m.assertEqual(m.top.callFunc("TestErrorRetry", content), 150.0)
|
||||||
|
m.assertEqual(content.url, "http://b", "retried the next stream url")
|
||||||
|
end function
|
||||||
|
|
||||||
@it("the error dialog displays every captured error field, not just the category")
|
@it("the error dialog displays every captured error field, not just the category")
|
||||||
function _()
|
function _()
|
||||||
' Real Roku Video error captured on device (an http stream failure, 502 manifest).
|
' Real Roku Video error captured on device (an http stream failure, 502 manifest).
|
||||||
@@ -1072,7 +1095,7 @@ namespace Tests
|
|||||||
classified[name] = "axis"
|
classified[name] = "axis"
|
||||||
end for
|
end for
|
||||||
' flags / scratch — one-shot latches and counters with a single consuming path.
|
' flags / scratch — one-shot latches and counters with a single consuming path.
|
||||||
for each name in ["onCloseCalled", "ignoreNextFinished", "videoPlayedSuccessfully", "firstFrameSeen", "showFullScreenHint", "repauseAfterSeek", "seekToPercent", "loadingSetSeekMs", "watchTimeMarker", "reportWatchTime", "errorDialogNode", "lastCommitSeq", "lastFinishSeq", "liveAstSeconds", "liveFallbackEdgeMs", "liveFallbackAtSeconds", "liveBadgeHoldActive"]
|
for each name in ["onCloseCalled", "ignoreNextFinished", "videoPlayedSuccessfully", "firstFrameSeen", "showFullScreenHint", "repauseAfterSeek", "loadingSetSeekMs", "watchTimeMarker", "reportWatchTime", "errorDialogNode", "lastCommitSeq", "lastFinishSeq", "liveAstSeconds", "liveFallbackEdgeMs", "liveFallbackAtSeconds", "liveBadgeHoldActive"]
|
||||||
classified[name] = "flag"
|
classified[name] = "flag"
|
||||||
end for
|
end for
|
||||||
' NOT coordinator state — node-scope + test-environment entries, pinned EXPLICITLY (no hidden
|
' NOT coordinator state — node-scope + test-environment entries, pinned EXPLICITLY (no hidden
|
||||||
|
|||||||
Reference in new issue
Block a user