Add seek field to player
This commit is contained in:
1 parent
3bb7746d50
commit
810ef60770
16 files changed
+685
-52
No files matched your search
@@ -100,6 +100,13 @@ the playing edge; the device auto-resumes on any seek).
|
||||
## Lounge takeover
|
||||
|
||||
A transport freezes the video, so an external resume from the linked phone (Lounge sets `control=resume` on the
|
||||
player) is caught in `OnControlChange` and takes over: cancel the transport, hide the bif/chrome, and play from
|
||||
the phone-seeked position. VPD itself only ever resumes at idle, so a resume under a transport is unambiguously
|
||||
external.
|
||||
player) is caught in `OnControlChange` and takes over: cancel the transport, hide the bif/chrome, and play. VPD
|
||||
itself only ever resumes at idle, so a resume under a transport is unambiguously external.
|
||||
|
||||
## Seeks
|
||||
|
||||
`ApplySeek` is the one writer of the device's `seek`. Anything outside the player seeks through the `setSeek`
|
||||
field: `OnSetSeek` routes it through the transport (`ForceIdleSeek`). It keeps the play state, as the
|
||||
YouTube receiver does (the device resumes on any seek, so a paused video is re-paused on landing); a seek under a
|
||||
transport takes over like the resume above, cancelling it and resuming from the target. One that arrives while
|
||||
the content loads becomes the content-load seek.
|
||||
@@ -417,7 +417,7 @@ namespace TransportController
|
||||
if firstEnter
|
||||
if m.transportMode = TransportController.Mode.Idle
|
||||
m.FreezeForTransport() ' the video FREEZES (deferred if a play-through seek is still settling)
|
||||
m.cursorMs = m.SnapToGrid(m.positionMs, m.storyboardStepMs)
|
||||
m.cursorMs = m.SnapToGrid(m.cursorMs, m.storyboardStepMs)
|
||||
end if
|
||||
m.transportMode = TransportController.Mode.Scrub
|
||||
m.scanLevel = 0
|
||||
@@ -467,7 +467,6 @@ namespace TransportController
|
||||
if m.transportMode <> TransportController.Mode.Scan
|
||||
if m.transportMode = TransportController.Mode.Idle
|
||||
m.FreezeForTransport()
|
||||
m.cursorMs = m.positionMs
|
||||
end if
|
||||
m.transportMode = TransportController.Mode.Scan
|
||||
m.scrubHeldDir = 0
|
||||
@@ -506,7 +505,6 @@ namespace TransportController
|
||||
if m.transportMode = TransportController.Mode.LiveDvr
|
||||
return false
|
||||
end if
|
||||
m.cursorMs = m.positionMs
|
||||
m.transportMode = TransportController.Mode.LiveDvr
|
||||
m.scanLevel = 0
|
||||
m.scanDir = 0
|
||||
@@ -692,17 +690,15 @@ namespace TransportController
|
||||
' ------------------------------------------------------------------------------------------------
|
||||
function Replay() as void
|
||||
' InstantReplay works from ANY state. From a transport (frozen) it cancels it and RESUMES from
|
||||
' cursor-20s; from idle it just seeks -20s and keeps the play state. Reference is the cursor (= position
|
||||
' while idle).
|
||||
' cursor-20s; from idle it just seeks -20s and keeps the play state. Reference is the cursor (while idle,
|
||||
' the playhead, or a seek target that has not landed yet).
|
||||
wasTransport = (m.transportMode <> TransportController.Mode.Idle)
|
||||
' spamming InstantReplay must ACCUMULATE: while a prior replay seek is still in flight, base off the
|
||||
' LAST target so each press goes another -20s, not off the stale position (all presses landing together).
|
||||
if m.replayPending
|
||||
base = m.replayTargetMs
|
||||
else if wasTransport
|
||||
base = m.cursorMs ' was frozen -> resume from where the cursor sits
|
||||
else
|
||||
base = m.positionMs
|
||||
base = m.cursorMs
|
||||
end if
|
||||
control = TransportController.Control.None ' from idle: keep playing, no state change
|
||||
if wasTransport
|
||||
@@ -757,11 +753,26 @@ namespace TransportController
|
||||
end if
|
||||
end function
|
||||
|
||||
' An EXTERNAL authority (SponsorBlock skip) seeks while a transport may be active. Route it THROUGH the
|
||||
' brain so the device never diverges: reset to idle and emit the seek as a normal intent. keepPlaying
|
||||
' preserves the current play state (control=none); else resume.
|
||||
' An EXTERNAL authority seeks while a transport may be active. The cursor goes to the target before the
|
||||
' seek lands, so the idle bar, a Replay, and a transport entered meanwhile all start from it. On live, a
|
||||
' target at or past the effective edge seeks to the edge, as a commit there does.
|
||||
function ForceIdleSeek(targetMs as integer, keepPlaying as boolean) as void
|
||||
m.ResetToIdle()
|
||||
m.replayPending = false
|
||||
if m.isLive
|
||||
if TransportController.IsLiveEdgeSentinelMs(targetMs) or (m.edgeMs > 0 and targetMs >= m.LiveEdgeMs())
|
||||
targetMs = TransportController.LIVE_EDGE_SEEK_MS
|
||||
m.cursorMs = m.LiveEdgeMs()
|
||||
else
|
||||
targetMs = m.ClampToTimeline(targetMs, m.LiveFloorMs(), m.edgeMs)
|
||||
m.cursorMs = targetMs
|
||||
end if
|
||||
m.RecomputeLive()
|
||||
else
|
||||
targetMs = m.ClampToTimeline(targetMs, 0, m.durationMs)
|
||||
m.positionMs = targetMs ' the idle VOD bar reads positionMs
|
||||
m.cursorMs = targetMs
|
||||
end if
|
||||
control = TransportController.Control.Resume
|
||||
if keepPlaying
|
||||
control = TransportController.Control.None
|
||||
@@ -866,6 +877,15 @@ namespace TransportController
|
||||
m.timerCmdRepeat = false
|
||||
end function
|
||||
|
||||
' Clamp to [lo, hi]; hi <= 0 is a timeline end not known yet, so only the floor applies. An external seek
|
||||
' can arrive while the content loads; transport input is dropped until the first frame, when it is known.
|
||||
function ClampToTimeline(value as integer, lo as integer, hi as integer) as integer
|
||||
if hi <= 0
|
||||
hi = -1
|
||||
end if
|
||||
return m.Clamp(value, lo, hi)
|
||||
end function
|
||||
|
||||
function Clamp(value as integer, lo as integer, hi as integer) as integer
|
||||
if value < lo
|
||||
return lo
|
||||
|
||||
@@ -56,6 +56,8 @@ function Initialize()
|
||||
m.reportWatchTime = 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.
|
||||
m.loadingSetSeekMs = -1
|
||||
|
||||
m.errorDialogNode = invalid
|
||||
m.ignoreNextFinished = false ' a retry replay -> swallow the next "finished" edge
|
||||
@@ -70,9 +72,9 @@ function Initialize()
|
||||
m.armedTimerId = TransportController.Timer.None ' which module timer the single transportTimer holds
|
||||
m.lastCommitSeq = 0
|
||||
m.lastFinishSeq = 0
|
||||
' a keep-playing seek (SponsorBlock skip / InstantReplay) was issued while the device was PAUSED. The
|
||||
' device auto-resumes on any seek (autoplayAfterSeek only governs resume-after-REBUFFER per the Video
|
||||
' docs), so the paused state is preserved by re-pausing on the next playing edge.
|
||||
' a keep-playing seek was issued while the device was PAUSED. The device auto-resumes on any seek
|
||||
' (autoplayAfterSeek only governs resume-after-REBUFFER per the Video docs), so the paused state is preserved
|
||||
' by re-pausing on the next playing edge.
|
||||
m.repauseAfterSeek = false
|
||||
' live edge clock anchor: the manifest's availabilityStartTime (Playlet generates it), as epoch seconds.
|
||||
' The edge is then wallClock - anchor — continuous through pauses/rebuffers/startup. The fallback pair
|
||||
@@ -166,6 +168,7 @@ function OnNodeReady()
|
||||
m.top.ObserveField("thumbnailTiles", FuncName(OnThumbnailTiles))
|
||||
' an external resume/play (the linked phone via Lounge) under an active transport must take over.
|
||||
m.top.ObserveField("control", FuncName(OnControlChange))
|
||||
m.top.ObserveField("setSeek", FuncName(OnSetSeek))
|
||||
m.top.ObserveField("bufferingStatus", FuncName(OnBufferingStatus))
|
||||
m.top.ObserveField("playStartInfo", FuncName(OnPlayStartInfo))
|
||||
|
||||
@@ -186,10 +189,10 @@ end function
|
||||
'===============================================================================
|
||||
function ApplyTransport() as void
|
||||
' A transport freezes the video. While one is active, disable auto-resume-after-rebuffer so an in-flight or
|
||||
' pending seek (a replay that kept playing, a SponsorBlock skip) can't un-pause the freeze when it completes;
|
||||
' restored to the default at idle so commit's resume + the normal seek-resume behave. But NOT while a
|
||||
' play-through seek is still settling: that seek must still reach "playing" so EnforceTransportFreeze can
|
||||
' freeze it cleanly — disabling autoplay here would strand it buffering. seekSettling clears at state=playing.
|
||||
' pending keep-playing seek can't un-pause the freeze when it completes; restored to the default at idle so
|
||||
' commit's resume + the normal seek-resume behave. But NOT while a play-through seek is still settling: that
|
||||
' seek must still reach "playing" so EnforceTransportFreeze can freeze it cleanly — disabling autoplay here
|
||||
' would strand it buffering. seekSettling clears at state=playing.
|
||||
' Write-guarded: this runs on every position tick, and most ticks don't change the value.
|
||||
autoplayAfterSeek = (m.transport.transportMode = TransportController.Mode.Idle) or m.transport.seekSettling
|
||||
if m.top.autoplayAfterSeek <> autoplayAfterSeek
|
||||
@@ -307,7 +310,8 @@ function PushTransportToRenderers() as void
|
||||
end if
|
||||
end function
|
||||
|
||||
' Apply a seek (ms). The live "jump to edge" sentinel maps to the live-end seek the OS understands.
|
||||
' Apply a seek (ms): the one writer of the device's `seek`. The live "jump to edge" sentinel maps to the
|
||||
' live-end seek the OS understands.
|
||||
function ApplySeek(seekMs as integer) as void
|
||||
if TransportController.IsLiveEdgeSentinelMs(seekMs)
|
||||
m.top.seek = 999999
|
||||
@@ -1035,8 +1039,8 @@ function OnFullScreenHintTimer() as void
|
||||
end function
|
||||
|
||||
' A resume/play arriving while a transport is active is necessarily external: VPD only ever resumes/plays at
|
||||
' idle, so this is the linked phone (Lounge) seeking + resuming. The phone action wins — cancel the scrub/scan
|
||||
' (the bif + chrome clear) and let the video play from where the phone seeked.
|
||||
' idle, so this is the linked phone (Lounge) resuming. The phone action wins — cancel the scrub/scan (the bif +
|
||||
' chrome clear) and let the video play.
|
||||
function OnControlChange(event as object) as void
|
||||
if m.onCloseCalled = true
|
||||
return
|
||||
@@ -1053,6 +1057,26 @@ function OnControlChange(event as object) as void
|
||||
end if
|
||||
end function
|
||||
|
||||
' Keeps the play state; a frozen transport resumes, as its commit would.
|
||||
function OnSetSeek(event as object) as void
|
||||
if m.onCloseCalled = true
|
||||
return
|
||||
end if
|
||||
seekMs = Int(event.getData() * 1000)
|
||||
LogDebug("external seek ->", seekMs)
|
||||
if m.videoContentJob <> invalid
|
||||
m.loadingSetSeekMs = seekMs
|
||||
return
|
||||
end if
|
||||
m.seekToPercent = invalid
|
||||
wasTransport = (m.transport.transportMode <> TransportController.Mode.Idle)
|
||||
m.transport.ForceIdleSeek(seekMs, not wasTransport)
|
||||
ApplyTransport()
|
||||
if wasTransport
|
||||
HideChromeNow()
|
||||
end if
|
||||
end function
|
||||
|
||||
'===============================================================================
|
||||
' Content load, initial seek, previous-player handoff, close.
|
||||
'===============================================================================
|
||||
@@ -1250,15 +1274,21 @@ function SeekToInitialPosition(content as object) as void
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
if m.loadingSetSeekMs <> -1
|
||||
LogDebug("seeking to the setSeek that arrived while loading:", m.loadingSetSeekMs)
|
||||
ApplySeek(m.loadingSetSeekMs)
|
||||
m.loadingSetSeekMs = -1
|
||||
return
|
||||
end if
|
||||
if content.Live = true
|
||||
LogDebug("seeking to end of live stream")
|
||||
m.top.seek = 999999
|
||||
ApplySeek(TransportController.LIVE_EDGE_SEEK_MS)
|
||||
return
|
||||
end if
|
||||
timestamp = ValidInt(content.timestamp)
|
||||
if timestamp > 0
|
||||
LogDebug("seeking to timestamp:", timestamp)
|
||||
m.top.seek = content.timestamp
|
||||
ApplySeek(timestamp * 1000)
|
||||
return
|
||||
end if
|
||||
percentDurationWatched = ValidFloat(content.percentDurationWatched)
|
||||
@@ -1285,7 +1315,7 @@ function SeekToPercentOfDuration() as void
|
||||
seek = (MathUtils.Clamp(seekToPercent, 0, 100) / 100.0) * duration
|
||||
if seek > 0
|
||||
LogDebug("seeking to percent watched ->", seek)
|
||||
m.top.seek = seek
|
||||
ApplySeek(Int(seek * 1000))
|
||||
end if
|
||||
end function
|
||||
|
||||
@@ -1474,6 +1504,7 @@ function OnClose() as void
|
||||
m.top.unobserveField("duration")
|
||||
m.top.unobserveField("thumbnailTiles")
|
||||
m.top.unobserveField("control")
|
||||
m.top.unobserveField("setSeek")
|
||||
m.top.unobserveField("bufferingStatus")
|
||||
m.top.unobserveField("playStartInfo")
|
||||
m.top.unobserveField("close")
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
<field id="minRect" type="rect2D" value="[834,460,426,240]" />
|
||||
<field id="maxRect" type="rect2D" value="[0,0,1280,720]" />
|
||||
<field id="close" type="boolean" alwaysNotify="true" />
|
||||
<field id="setSeek" type="float" alwaysNotify="true" />
|
||||
<function name="PlayWithContent" />
|
||||
</interface>
|
||||
<!-- Init() lives in its own file so VideoPlayerDev.bs (the coordinator logic) has no Init and is importable by
|
||||
|
||||
@@ -70,7 +70,7 @@ function TestSetup() as void
|
||||
' nudge counter above — stacked observers fire a handler once per prior TestSetup on every write,
|
||||
' and OnPosition's latency learning reads two identical fires as a CONFIRMED min-gap, poisoning
|
||||
' LiveEdgeMs for any live test that runs after another test in the suite.
|
||||
for each deviceField in ["state", "position", "duration", "close", "thumbnailTiles", "control", "bufferingStatus", "playStartInfo"]
|
||||
for each deviceField in ["state", "position", "duration", "close", "thumbnailTiles", "control", "setSeek", "bufferingStatus", "playStartInfo"]
|
||||
m.top.unobserveField(deviceField)
|
||||
end for
|
||||
|
||||
@@ -81,8 +81,14 @@ function TestSetup() as void
|
||||
m.top.position = 0
|
||||
m.top.duration = 0
|
||||
m.top.seek = 0
|
||||
m.top.suppressCaptions = false ' a test that minimized leaves it set; the container below starts fullscreen
|
||||
m.top.autoplayAfterSeek = true
|
||||
|
||||
OnNodeReady()
|
||||
|
||||
' the children survive across tests too: clear what a previous test's transport or live content left.
|
||||
m.transportTimer.control = "none"
|
||||
m.trickPlayBar.isLive = false
|
||||
end function
|
||||
|
||||
function OnTestNudge() as void
|
||||
@@ -122,6 +128,21 @@ function TestSeedSponsorBlock(segments as object) as void
|
||||
m.sponsorblock.segments = segments
|
||||
end function
|
||||
|
||||
' TestSeekToInitialPosition — the content-load seek (live edge / resume timestamp / percent watched), minus the
|
||||
' content job.
|
||||
function TestSeekToInitialPosition(content as object) as void
|
||||
SeekToInitialPosition(content)
|
||||
end function
|
||||
|
||||
' TestSetContentLoading — a VideoContentJob in flight (or not), minus the job.
|
||||
function TestSetContentLoading(loading as boolean) as void
|
||||
if loading
|
||||
m.videoContentJob = CreateObject("roSGNode", "Node")
|
||||
else
|
||||
m.videoContentJob = invalid
|
||||
end if
|
||||
end function
|
||||
|
||||
' TestFireLiveBadgeHold — fire the liveBadgeHold timer's handler now (the spec can't wait out the real timer).
|
||||
function TestFireLiveBadgeHold() as void
|
||||
OnLiveBadgeHoldFire()
|
||||
@@ -235,6 +256,35 @@ function TestSnapshot() as object
|
||||
forceLiveBadge: m.trickPlayBar.forceLiveBadge
|
||||
liveBadgeShown: m.trickPlayBar.findNode("liveLabel").visible
|
||||
barRemainingText: m.trickPlayBar.findNode("remainingLabel").text
|
||||
replayPending: m.transport.replayPending
|
||||
transportTimerControl: m.transportTimer.control
|
||||
buttonRowVisible: m.buttonRow.visible
|
||||
barPositionMs: m.trickPlayBar.positionMs
|
||||
spinnerMode: m.spinner.mode
|
||||
brain: TestBrainSnapshot()
|
||||
}
|
||||
end function
|
||||
|
||||
' The brain's output fields in the shape PlayerInvariants.CheckBrain expects.
|
||||
function TestBrainSnapshot() as object
|
||||
t = m.transport
|
||||
return {
|
||||
transportMode: t.transportMode
|
||||
glyph: t.glyph
|
||||
scanLevel: t.scanLevel
|
||||
scanDir: t.scanDir
|
||||
scrubHeldDir: t.scrubHeldDir
|
||||
scrubHoldTicks: t.scrubHoldTicks
|
||||
scrubStepMs: t.scrubStepMs
|
||||
storyboardStepMs: t.storyboardStepMs
|
||||
cursorMs: t.cursorMs
|
||||
positionMs: t.positionMs
|
||||
durationMs: t.durationMs
|
||||
edgeMs: t.edgeMs
|
||||
liveOffsetMs: t.liveOffsetMs
|
||||
atLiveEdge: t.atLiveEdge
|
||||
isLive: t.isLive
|
||||
replayPending: t.replayPending
|
||||
}
|
||||
end function
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
<field id="minRect" type="rect2D" value="[834,460,426,240]" />
|
||||
<field id="maxRect" type="rect2D" value="[0,0,1280,720]" />
|
||||
<field id="close" type="boolean" alwaysNotify="true" />
|
||||
<field id="setSeek" type="float" alwaysNotify="true" />
|
||||
<!-- test-only probe: how many times the coordinator pulsed ButtonRow.nudge (TestSetup observes it). -->
|
||||
<field id="nudgeCount" type="integer" />
|
||||
<!-- the Video-only method Initialize calls, plus the spec's drivers (callFunc reaches only interface funcs). -->
|
||||
@@ -56,6 +57,8 @@
|
||||
<function name="TestSetControl" />
|
||||
<function name="TestSetLive" />
|
||||
<function name="TestSeedSponsorBlock" />
|
||||
<function name="TestSeekToInitialPosition" />
|
||||
<function name="TestSetContentLoading" />
|
||||
<function name="TestFireLiveBadgeHold" />
|
||||
<function name="TestKillAutoHide" />
|
||||
<function name="TestFinishChromeFadeOut" />
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
import "pkg:/components/VideoPlayerDev/PlayerCoordinatorLogic.bs"
|
||||
import "pkg:/components/VideoPlayerDev/TransportController.bs"
|
||||
import "pkg:/components/VideoPlayerDev/VideoNode.bs"
|
||||
import "pkg:/source/tests/VideoPlayerDev/PlayerInvariants.bs"
|
||||
import "pkg:/source/utils/ArrayUtils.bs"
|
||||
import "pkg:/source/utils/RemoteKeys.bs"
|
||||
|
||||
namespace Tests
|
||||
@@ -133,7 +135,7 @@ namespace Tests
|
||||
m.assertEqual(mid.transportMode, TransportController.Mode.Scrub)
|
||||
m.assertEqual(mid.control, VideoControl.Pause)
|
||||
|
||||
' the phone seeks + resumes: Lounge sets control=resume directly on the player node.
|
||||
' the phone resumes: Lounge sets control=resume directly on the player node.
|
||||
m.top.callFunc("TestSetControl", VideoControl.Resume)
|
||||
after = m.Snap()
|
||||
m.assertEqual(after.transportMode, TransportController.Mode.Idle, "the external resume cancels the transport")
|
||||
@@ -141,6 +143,230 @@ namespace Tests
|
||||
m.assertTrue(after.autoplay, "autoplay restored so a settling seek won't re-freeze the takeover")
|
||||
end function
|
||||
|
||||
' --- external seek (setSeek) ---
|
||||
|
||||
' Each arm is asserted: a state that silently failed to arm makes its row vacuous.
|
||||
function ArmSeekState(state as string) as void
|
||||
m.top.callFunc("TestSetup")
|
||||
if state = "first load"
|
||||
m.top.callFunc("TestSetState", VideoState.Buffering)
|
||||
m.assertEqual(m.Snap().spinnerMode, SpinMode.Loading, "armed: " + state)
|
||||
return
|
||||
end if
|
||||
m.top.callFunc("TestSetState", VideoState.Playing)
|
||||
if Left(state, 4) = "live"
|
||||
m.top.callFunc("TestSetLive", 43200000) ' 12h edge, 4h window: floor 8h
|
||||
else
|
||||
m.top.duration = 600.0
|
||||
m.top.position = 300.0
|
||||
end if
|
||||
if state = "idle paused"
|
||||
m.top.callFunc("TestKey", RemoteKeys.Play, true)
|
||||
m.top.callFunc("TestSetState", VideoState.Paused)
|
||||
else if state = "idle buffering"
|
||||
m.top.callFunc("TestSetState", VideoState.Buffering)
|
||||
else if state = "repause pending"
|
||||
m.top.callFunc("TestKey", RemoteKeys.Play, true)
|
||||
m.top.callFunc("TestSetState", VideoState.Paused)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Replay, true)
|
||||
m.top.callFunc("TestSetState", VideoState.Buffering)
|
||||
else if state = "replay in flight"
|
||||
m.top.callFunc("TestKey", RemoteKeys.Replay, true)
|
||||
m.assertTrue(m.Snap().replayPending, "armed: " + state)
|
||||
else if state = "chrome/bar"
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true)
|
||||
m.assertTrue(m.Snap().chromeShown, "armed: " + state)
|
||||
else if state = "chrome fading"
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Back, true)
|
||||
m.assertTrue(m.Snap().chromeFadingOut, "armed: " + state)
|
||||
else if state = "minimized"
|
||||
m.top.container.fullscreen = false
|
||||
m.assertTrue(m.Snap().suppressCaptions, "armed: " + state)
|
||||
else if state = "scrub" or state = "live dvr"
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, false)
|
||||
m.top.callFunc("TestSetState", VideoState.Paused)
|
||||
else if state = "scrub held"
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true)
|
||||
m.top.callFunc("TestSetState", VideoState.Paused)
|
||||
else if state = "scan"
|
||||
m.top.callFunc("TestKey", RemoteKeys.FastForward, true)
|
||||
m.top.callFunc("TestSetState", VideoState.Paused)
|
||||
else if state = "live scan"
|
||||
m.top.callFunc("TestKey", RemoteKeys.Rewind, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Rewind, false)
|
||||
m.top.callFunc("TestSetState", VideoState.Paused)
|
||||
else if state = "deferred freeze"
|
||||
' commit, then an immediate re-scrub while the commit's seek is still settling: no freeze sent.
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, false)
|
||||
m.top.callFunc("TestSetState", VideoState.Paused)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Ok, true)
|
||||
m.top.callFunc("TestSetState", VideoState.Buffering)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true)
|
||||
m.assertTrue(m.Snap().seekSettling, "armed: " + state)
|
||||
end if
|
||||
snap = m.Snap()
|
||||
mode = snap.transportMode
|
||||
m.assertEqual(snap.brain.isLive, Left(state, 4) = "live", "armed: " + state)
|
||||
if state = "scrub" or state = "scrub held" or state = "deferred freeze"
|
||||
m.assertEqual(mode, TransportController.Mode.Scrub, "armed: " + state)
|
||||
else if state = "scan"
|
||||
m.assertEqual(mode, TransportController.Mode.Scan, "armed: " + state)
|
||||
else if state = "live dvr"
|
||||
m.assertEqual(mode, TransportController.Mode.LiveDvr, "armed: " + state)
|
||||
m.assertEqual(snap.brain.scanLevel, 0, "armed: " + state)
|
||||
else if state = "live scan"
|
||||
m.assertEqual(mode, TransportController.Mode.LiveDvr, "armed: " + state)
|
||||
m.assertTrue(snap.brain.scanLevel >= 1, "armed: " + state)
|
||||
else
|
||||
m.assertEqual(mode, TransportController.Mode.Idle, "armed: " + state)
|
||||
end if
|
||||
end function
|
||||
|
||||
' Every state a seek from outside the player (setSeek) can arrive in. It lands idle at the target with the
|
||||
' brain consistent; it keeps the play state (a paused video is re-paused on landing), and out of a
|
||||
' transport it resumes, the chrome cleared.
|
||||
@it("setSeek in every reachable player state lands idle at the target, keeping the play state")
|
||||
function _()
|
||||
transports = ["scrub", "scrub held", "scan", "deferred freeze", "live dvr", "live scan"]
|
||||
paused = ["idle paused", "repause pending"]
|
||||
states = ["idle playing", "idle buffering", "replay in flight", "chrome/bar", "chrome fading", "minimized", "first load", "live idle"]
|
||||
states.Append(paused)
|
||||
states.Append(transports)
|
||||
for each state in states
|
||||
m.ArmSeekState(state)
|
||||
wasTransport = ArrayUtils.IndexOfString(transports, state) <> -1
|
||||
targetS = 30.5
|
||||
if Left(state, 4) = "live"
|
||||
targetS = 40000.0 ' inside the live window
|
||||
end if
|
||||
before = m.Snap()
|
||||
m.top.callFunc("TestSetControl", VideoControl.None) ' so a control write below is the seek's
|
||||
m.top.seek = -1
|
||||
|
||||
m.top.setSeek = targetS
|
||||
snap = m.Snap()
|
||||
where = " — " + state
|
||||
m.assertEqual(snap.transportMode, TransportController.Mode.Idle, "idle" + where)
|
||||
m.assertFalse(snap.bifVisible, "no bif" + where)
|
||||
m.assertEqual(Int(m.top.seek * 1000), Int(targetS * 1000), "seeked to the target" + where)
|
||||
m.assertTrue(snap.autoplay, "autoplay restored" + where)
|
||||
m.assertFalse(snap.replayPending, "no replay chain" + where)
|
||||
m.assertEqual(snap.transportTimerControl, "stop", "transport timer stopped" + where)
|
||||
brainCheck = PlayerInvariants.CheckBrain(snap.brain)
|
||||
m.assertTrue(brainCheck.ok, brainCheck.failed + where)
|
||||
if wasTransport
|
||||
m.assertEqual(snap.control, VideoControl.Resume, "the transport resumes from the target" + where)
|
||||
m.assertFalse(snap.chromeShown, "the chrome cleared" + where)
|
||||
else
|
||||
m.assertEqual(snap.control, VideoControl.None, "no control write: the play state is kept" + where)
|
||||
m.assertEqual(snap.spinnerMode, before.spinnerMode, "spinner untouched" + where)
|
||||
m.assertEqual(snap.chromeShown, before.chromeShown, "chrome untouched" + where)
|
||||
m.assertEqual(snap.chromeFadingOut, before.chromeFadingOut, "chrome fade untouched" + where)
|
||||
end if
|
||||
if state = "chrome/bar"
|
||||
m.assertEqual(snap.barPositionMs, Int(targetS * 1000), "the visible bar shows the target before it lands")
|
||||
end if
|
||||
|
||||
' the device lands and (on any seek) plays.
|
||||
m.top.callFunc("TestSetState", VideoState.Playing)
|
||||
landed = m.Snap()
|
||||
m.assertEqual(landed.transportMode, TransportController.Mode.Idle, "still idle on landing" + where)
|
||||
if ArrayUtils.IndexOfString(paused, state) <> -1
|
||||
m.assertEqual(landed.control, VideoControl.Pause, "re-paused on landing" + where)
|
||||
else if wasTransport
|
||||
m.assertEqual(landed.control, VideoControl.Resume, "not re-frozen on landing" + where)
|
||||
else
|
||||
m.assertEqual(landed.control, VideoControl.None, "untouched on landing" + where)
|
||||
end if
|
||||
end for
|
||||
end function
|
||||
|
||||
@it("setSeek under a held scrub: the later key-up is a no-op at idle")
|
||||
function _()
|
||||
m.ArmSeekState("scrub held")
|
||||
m.top.setSeek = 30.5
|
||||
control = m.Snap().control
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, false)
|
||||
snap = m.Snap()
|
||||
m.assertEqual(snap.transportMode, TransportController.Mode.Idle)
|
||||
m.assertEqual(snap.control, control)
|
||||
end function
|
||||
|
||||
@it("setSeek ends an InstantReplay chain: the next replay goes back from the setSeek target")
|
||||
function _()
|
||||
m.ArmSeekState("replay in flight")
|
||||
m.top.setSeek = 100.0
|
||||
m.top.callFunc("TestKey", RemoteKeys.Replay, true)
|
||||
m.assertEqual(Int(m.top.seek * 1000), 80000)
|
||||
end function
|
||||
|
||||
@it("setSeek seeks every time it is set, the same target included")
|
||||
function _()
|
||||
m.top.setSeek = 42.0
|
||||
m.assertEqual(Int(m.top.seek * 1000), 42000)
|
||||
m.top.seek = -1
|
||||
m.top.setSeek = 42.0
|
||||
m.assertEqual(Int(m.top.seek * 1000), 42000)
|
||||
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")
|
||||
function _()
|
||||
m.top.callFunc("TestSetContentLoading", true)
|
||||
m.top.seek = -1
|
||||
m.top.setSeek = 30.5
|
||||
m.assertEqual(m.top.seek, -1.0, "no seek while there is no content to seek")
|
||||
m.top.callFunc("TestSetContentLoading", false)
|
||||
content = CreateObject("roSGNode", "ContentNode")
|
||||
content.AddFields({ timestamp: 42 })
|
||||
m.top.callFunc("TestSeekToInitialPosition", content)
|
||||
m.assertEqual(Int(m.top.seek * 1000), 30500)
|
||||
' consumed: a later content-load seek (an error retry) goes back to the content's own start.
|
||||
m.top.callFunc("TestSeekToInitialPosition", content)
|
||||
m.assertEqual(Int(m.top.seek * 1000), 42000)
|
||||
end function
|
||||
|
||||
' --- content-load seek ---
|
||||
|
||||
@it("the content-load seek goes to the live edge on live content")
|
||||
function _()
|
||||
content = CreateObject("roSGNode", "ContentNode")
|
||||
content.Live = true
|
||||
m.top.callFunc("TestSeekToInitialPosition", content)
|
||||
m.assertEqual(m.top.seek, 999999.0)
|
||||
end function
|
||||
|
||||
@it("the content-load seek goes to the resume timestamp")
|
||||
function _()
|
||||
content = CreateObject("roSGNode", "ContentNode")
|
||||
content.AddFields({ timestamp: 42 })
|
||||
m.top.callFunc("TestSeekToInitialPosition", content)
|
||||
m.assertEqual(Int(m.top.seek * 1000), 42000)
|
||||
end function
|
||||
|
||||
@it("the content-load seek goes to the percent watched once the duration is known")
|
||||
function _()
|
||||
content = CreateObject("roSGNode", "ContentNode")
|
||||
content.AddFields({ percentDurationWatched: 25.0 })
|
||||
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)
|
||||
end function
|
||||
|
||||
@it("the error dialog displays every captured error field, not just the category")
|
||||
function _()
|
||||
' Real Roku Video error captured on device (an http stream failure, 502 manifest).
|
||||
@@ -742,7 +968,7 @@ namespace Tests
|
||||
classified[name] = "axis"
|
||||
end for
|
||||
' flags / scratch — one-shot latches and counters with a single consuming path.
|
||||
for each name in ["onCloseCalled", "ignoreNextFinished", "videoPlayedSuccessfully", "firstFrameSeen", "showFullScreenHint", "repauseAfterSeek", "seekToPercent", "watchTimeMarker", "reportWatchTime", "errorDialogNode", "lastCommitSeq", "lastFinishSeq", "liveAstSeconds", "liveFallbackEdgeMs", "liveFallbackAtSeconds", "liveBadgeHoldActive"]
|
||||
for each name in ["onCloseCalled", "ignoreNextFinished", "videoPlayedSuccessfully", "firstFrameSeen", "showFullScreenHint", "repauseAfterSeek", "seekToPercent", "loadingSetSeekMs", "watchTimeMarker", "reportWatchTime", "errorDialogNode", "lastCommitSeq", "lastFinishSeq", "liveAstSeconds", "liveFallbackEdgeMs", "liveFallbackAtSeconds", "liveBadgeHoldActive"]
|
||||
classified[name] = "flag"
|
||||
end for
|
||||
' NOT coordinator state — node-scope + test-environment entries, pinned EXPLICITLY (no hidden
|
||||
@@ -802,7 +1028,7 @@ namespace Tests
|
||||
container.fullscreen = true
|
||||
' close the player (what the queue does when replacing the video), then throw every signal a dead
|
||||
' player might still receive at it: fullscreen flips (the * key), device edges from the async stop,
|
||||
' a stray control/seek write, late thumbnails and buffering/start info, a second close. OnClose unobserves them all.
|
||||
' a stray control/seek/setSeek write, late thumbnails and buffering/start info, a second close. OnClose unobserves them all.
|
||||
m.top.close = true
|
||||
container.fullscreen = false
|
||||
container.fullscreen = true
|
||||
@@ -813,6 +1039,8 @@ namespace Tests
|
||||
m.top.position = 12.0
|
||||
m.top.duration = 99.0
|
||||
m.top.seek = 5.0
|
||||
m.top.setSeek = 7.0
|
||||
m.assertEqual(m.top.seek, 5.0, "the closed player ignored the setSeek")
|
||||
m.top.thumbnailTiles = { x: [{ htiles: 1 }] }
|
||||
m.top.bufferingStatus = { isUnderrun: true, percentage: 0, prebufferDone: false, actualStart: 0 }
|
||||
m.top.playStartInfo = { start_type: "cseek", total_dur: 0.1 }
|
||||
|
||||
Reference in new issue
Block a user