Back buton behaviour on video player

This commit is contained in:
Brahim Hadriche committed 2026-07-04 20:46:05 -04:00
1 parent 5b8b69ba7b
commit fa90d8d2fd
12 files changed
+298 -39

No files matched your search

+1
View File
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Video Player HUD now focuses initially on the trackbar, instead of the pause button - Video Player HUD now focuses initially on the trackbar, instead of the pause button
- Pressing back cancels seek, hides UI, then closes the video player
## [0.48.1] - 2026-07-04 ## [0.48.1] - 2026-07-04
@@ -7,6 +7,16 @@ import "pkg:/source/utils/Types.bs"
' buffering-spinner gate. None of these touch a node, so they are plain functions of their inputs; the player ' buffering-spinner gate. None of these touch a node, so they are plain functions of their inputs; the player
' applies the results to the Video node, the chrome, and the renderers. ' applies the results to the Video node, the chrome, and the renderers.
' The chrome fade state the coordinator owns (the Chrome group opacity as one unit). Declared here (file
' scope, not in the namespace) because the Back ladder decides over it; the coordinator keeps using the
' bare ChromeMode.* names via its import of this file.
enum ChromeMode
Hidden = 0
FadingIn = 1
Shown = 2
FadingOut = 3
end enum
namespace PlayerCoordinatorLogic namespace PlayerCoordinatorLogic
' What an OK/Select press does while no transport is active. Live toggles the HUD without pausing; VOD ' What an OK/Select press does while no transport is active. Live toggles the HUD without pausing; VOD
@@ -25,6 +35,15 @@ namespace PlayerCoordinatorLogic
ResumeLiveTail = 3 ' live: the sliding DVR tail overtook the frozen playhead -> resolve forward, a re-pause cannot stick ResumeLiveTail = 3 ' live: the sliding DVR tail overtook the frozen playhead -> resolve forward, a re-pause cannot stick
end enum end enum
' The Back ladder. Priority = enum order: an active transport outranks the chrome, which outranks
' closing — a Back while ANY chrome is on screen never exits.
enum BackAction
CancelTransport = 0 ' a transport is active -> cancel it, keep watching, never exit
DismissChrome = 1 ' idle, chrome shown/fading in -> dismiss it (the same animated fade auto-hide uses)
None = 2 ' idle, chrome mid fade-out -> the dismissal is already underway: consume the press, let it finish
Close = 3 ' idle, chrome fully hidden -> nothing left to dismiss: close
end enum
' The buttons in the row above the trackbar, in focus order (the index). The COUNT is owned by ButtonRow ' The buttons in the row above the trackbar, in focus order (the index). The COUNT is owned by ButtonRow
' (m.buttons / its buttonCount field) — there is no separate count constant to keep in sync. ' (m.buttons / its buttonCount field) — there is no separate count constant to keep in sync.
enum PlayerButton enum PlayerButton
@@ -72,6 +91,23 @@ namespace PlayerCoordinatorLogic
return OkAction.Reveal return OkAction.Reveal
end function end function
' The Back decision. A press while the chrome is still visible in ANY form never exits: shown/fading-in
' dismisses (animated); mid fade-out the dismissal is already underway, so the press is consumed and the
' fade just finishes (the user can still see the UI, so Back must not read as "nothing left to undo").
' Only a fully hidden chrome falls through to Close.
function BackActionFor(transportMode as integer, chrome as integer) as integer
if transportMode <> TransportController.Mode.Idle
return BackAction.CancelTransport
end if
if chrome = ChromeMode.Shown or chrome = ChromeMode.FadingIn
return BackAction.DismissChrome
end if
if chrome = ChromeMode.FadingOut
return BackAction.None
end if
return BackAction.Close
end function
' The mid-stream buffering spinner shows only after the first frame, while idle, and while fullscreen. ' The mid-stream buffering spinner shows only after the first frame, while idle, and while fullscreen.
function ShouldShowBuffering(firstFrameSeen as boolean, transportMode as integer, fullscreen as boolean) as boolean function ShouldShowBuffering(firstFrameSeen as boolean, transportMode as integer, fullscreen as boolean) as boolean
return firstFrameSeen and transportMode = TransportController.Mode.Idle and fullscreen return firstFrameSeen and transportMode = TransportController.Mode.Idle and fullscreen
@@ -63,6 +63,14 @@ the exhaustive + seeded-fuzz suite (`TransportControllerCompleteness.spec.bs`).
predicate, so it is not in this catalog — it is enforced by `FreezeForTransport` and tested at the seam as predicate, so it is not in this catalog — it is enforced by `FreezeForTransport` and tested at the seam as
P-seam, `VideoPlayerDevSeam.spec.bs`.) P-seam, `VideoPlayerDevSeam.spec.bs`.)
Back is a ladder, also a transition property (not an INV-B snapshot predicate, since it rides `ChromeMode` —
a coordinator field, not a brain one): a transport active cancels it and keeps watching (on live the cancel
also resumes at the frozen playhead — idle-paused live has no OK-resume and cannot hold near the DVR floor
anyway; VOD stays paused, the settled cancel/commit asymmetry); else idle with the chrome up dismisses it
(the same animated fade auto-hide uses); else a chrome still mid fade-out consumes the press and lets the
fade finish (a visible chrome never exits); else nothing is left to dismiss and Back closes. Tested at the
seam, `VideoPlayerDevSeam.spec.bs` ("Back ladder").
**INV-D\* (device-seam)** — need the live `Video.state` (no brain field for it), so checked on-device by **INV-D\* (device-seam)** — need the live `Video.state` (no brain field for it), so checked on-device by
`assertPlayerInvariants()` after every input (`pressChecked`) in the integration harness: `assertPlayerInvariants()` after every input (`pressChecked`) in the integration harness:
@@ -132,10 +132,9 @@ namespace TransportController
private videoIntent as object = invalid private videoIntent as object = invalid
private intentSeq as integer = 0 private intentSeq as integer = 0
' commitSeq / exitSeq / finishSeq — pulse counters the coordinator compares to its last-seen value. ' commitSeq / finishSeq — pulse counters the coordinator compares to its last-seen value. finishSeq
' finishSeq pulses when a VOD commit lands at the very end (-> the coordinator finishes playback). ' pulses when a VOD commit lands at the very end (-> the coordinator finishes playback).
commitSeq as integer = 0 commitSeq as integer = 0
exitSeq as integer = 0
finishSeq as integer = 0 finishSeq as integer = 0
' timerCmd — the timer schedule the coordinator mirrors onto a real Timer node. ' timerCmd — the timer schedule the coordinator mirrors onto a real Timer node.
@@ -708,18 +707,24 @@ namespace TransportController
m.cursorMs = m.positionMs m.cursorMs = m.positionMs
end function end function
' Back while a transport is active: reset + pulse exit so the coordinator routes it (close). ' Reset an active transport to idle WITHOUT a seek/resume/exit pulse: the play/pause state is left
function Cancel() as void ' exactly as it was (no videoIntent emitted). Used by the involuntary resets — Minimize (Down), video
m.ResetToIdle() ' error, EOF finish, PiP/Lounge cutovers — which silently return to idle while the player keeps running.
m.exitSeq = m.exitSeq + 1
end function
' Minimize (Down): reset to idle WITHOUT a seek/resume/exit pulse. The play/pause state is left exactly as
' it was (no videoIntent emitted).
function ResetTransport() as void function ResetTransport() as void
m.ResetToIdle() m.ResetToIdle()
end function end function
' Back's rung-1 cancel: reset to idle, and on LIVE also resume at the frozen playhead (no seek — still
' behind the edge). Idle-paused live is a dead end: OK never resumes on live (it only toggles the HUD),
' the paused playhead drifts toward the DVR floor, and the device force-resumes it there anyway. VOD
' stays exactly where the freeze put it — paused (canceling and committing are intentionally asymmetric).
function CancelTransport() as void
m.ResetToIdle()
if m.isLive
m.EmitIntent(TransportController.Control.Resume, false, 0)
end if
end function
' An EXTERNAL authority (SponsorBlock skip) seeks while a transport may be active. Route it THROUGH the ' 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 ' 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. ' preserves the current play state (control=none); else resume.
@@ -31,13 +31,8 @@ const INV_D1_TELEMETRY_CAP = 3
' fields. Renderers self-derive visibility from transportMode (commit sets mode=idle and the bif vanishes by ' fields. Renderers self-derive visibility from transportMode (commit sets mode=idle and the bif vanishes by
' its own rule — no hide call needed). ' its own rule — no hide call needed).
' The coordinator owns the Chrome group opacity as one unit. ' ChromeMode (the Chrome group fade state, owned here as one unit) lives in PlayerCoordinatorLogic.bs —
enum ChromeMode ' the Back ladder decides over it.
Hidden = 0
FadingIn = 1
Shown = 2
FadingOut = 3
end enum
' Int values the coordinator pushes onto LoadBufferSpinner.mode. Kept local to avoid importing the component's ' Int values the coordinator pushes onto LoadBufferSpinner.mode. Kept local to avoid importing the component's
' .bs (which would collide on Init). ' .bs (which would collide on Init).
@@ -76,7 +71,6 @@ function Initialize()
m.focusedButton = 0 m.focusedButton = 0
m.armedTimerId = TransportController.Timer.None ' which module timer the single transportTimer holds m.armedTimerId = TransportController.Timer.None ' which module timer the single transportTimer holds
m.lastCommitSeq = 0 m.lastCommitSeq = 0
m.lastExitSeq = 0
m.lastFinishSeq = 0 m.lastFinishSeq = 0
' a keep-playing seek (SponsorBlock skip / InstantReplay) was issued while the device was PAUSED. The ' 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 ' device auto-resumes on any seek (autoplayAfterSeek only governs resume-after-REBUFFER per the Video
@@ -272,12 +266,6 @@ function ApplyTransport() as void
HideChrome() HideChrome()
end if end if
' Back while a transport was active -> the module pulses exitSeq -> close.
if m.transport.exitSeq <> m.lastExitSeq
m.lastExitSeq = m.transport.exitSeq
ClosePlayer()
end if
' a VOD commit at the very end pulses finishSeq: watched to the end -> PlayNext/close, no seek. ' a VOD commit at the very end pulses finishSeq: watched to the end -> PlayNext/close, no seek.
if m.transport.finishSeq <> m.lastFinishSeq if m.transport.finishSeq <> m.lastFinishSeq
m.lastFinishSeq = m.transport.finishSeq m.lastFinishSeq = m.transport.finishSeq
@@ -483,17 +471,34 @@ function OnPlayPress() as boolean
return true return true
end function end function
' Back — if a transport is active, cancel it then close; if minimized, the container restores; else close. ' Back — a ladder: a transport active > the chrome visible in any form > nothing left to dismiss.
' 1. transport active -> cancel it (keep watching, never exit; live also resumes)
' 2. idle, chrome shown -> dismiss it (the same animated fade auto-hide uses)
' 3. idle, chrome fading out -> no-op: the dismissal is already underway (a visible chrome never closes)
' 4. idle, chrome hidden -> close the player
function OnBackPress() as boolean function OnBackPress() as boolean
if m.transport.transportMode <> TransportController.Mode.Idle action = PlayerCoordinatorLogic.BackActionFor(m.transport.transportMode, m.chromeMode)
m.transport.Cancel() ApplyBackAction(action)
ApplyTransport() ' drains the exit pulse -> ClosePlayer
return true
end if
ClosePlayer()
return true return true
end function end function
' Apply the Back decision to the transport / chrome / player.
function ApplyBackAction(action as integer) as void
if action = PlayerCoordinatorLogic.BackAction.CancelTransport
m.transport.CancelTransport() ' live also emits a resume at the frozen playhead; VOD stays paused
ApplyTransport() ' drains the timer-stop + any resume intent, pushes mode=idle so the bif/glyph self-hide
' OnAutoHideFire no-ops (and does NOT rearm itself, repeat="false") while a transport is active, so a
' scrub/scan/liveDvr that outlasted the 5s auto-hide would leave the timer dead -- rearm it here or the
' chrome could be stuck shown forever.
ArmAutoHide()
else if action = PlayerCoordinatorLogic.BackAction.DismissChrome
HideChrome() ' the same animated 0.3s fade the 5s auto-hide uses -- not the instant HideChromeNow
else if action = PlayerCoordinatorLogic.BackAction.Close
ClosePlayer()
end if
' BackAction.None (mid fade-out) falls through: the press is consumed and the fade finishes on its own.
end function
'=============================================================================== '===============================================================================
' FOCUS (two-tier virtual focus) — the real focus stays on the Video node. Two tiers: the BAR (default on ' FOCUS (two-tier virtual focus) — the real focus stays on the Video node. Two tiers: the BAR (default on
' reveal; Left/Right scrub, the cursor grows) and the BUTTONS. Up/Down move between them; both exist only while ' reveal; Left/Right scrub, the cursor grows) and the BUTTONS. Up/Down move between them; both exist only while
@@ -40,7 +40,7 @@
<!-- Chrome auto-hide: only fires when transportMode=idle. --> <!-- Chrome auto-hide: only fires when transportMode=idle. -->
<Timer id="autoHide" duration="5" repeat="false" /> <Timer id="autoHide" duration="5" repeat="false" />
<!-- The one transport timer, (re)armed/stopped from TransportController.TakeTimerCmd; scrubRepeat / scan / <!-- The one transport timer, (re)armed/stopped from TransportController.TakeTimerCmd; scrubRepeat / scan /
liveEdgeTick all reuse this node, with the brain owning the schedule as data. --> replayToast all reuse this node, with the brain owning the schedule as data. -->
<Timer id="transportTimer" duration="0.6" repeat="false" /> <Timer id="transportTimer" duration="0.6" repeat="false" />
<!-- Live badge hold: a live reveal forces "● LIVE", then this fires to release it so the bar swaps to the <!-- Live badge hold: a live reveal forces "● LIVE", then this fires to release it so the bar swaps to the
offset M:SS when behind the edge. --> offset M:SS when behind the edge. -->
@@ -123,6 +123,21 @@ function TestFireLiveBadgeHold() as void
OnLiveBadgeHoldFire() OnLiveBadgeHoldFire()
end function end function
' TestKillAutoHide — model the one-shot auto-hide timer having FIRED (mid-transport it no-ops without
' rearming, leaving the timer dead). A fired Timer's control field still reads the last-written "start", so
' the spec must stop it explicitly — otherwise a rearm assertion could never fail.
function TestKillAutoHide() as void
m.autoHide.control = "stop"
end function
' TestFinishChromeFadeOut — complete the running 0.3s dismiss fade now (the spec can't wait it out).
' Stopping the Animation flips its state to "stopped", which drives the REAL OnChromeFadeOutState observer;
' the direct call after it makes the transition deterministic even if the observer is deferred.
function TestFinishChromeFadeOut() as void
m.chromeFadeOut.control = "stop"
OnChromeFadeOutState()
end function
' TestPlaybackErrorDialog — seed the error fields, drive OnVideoError down the dialog path, return the dialog's ' TestPlaybackErrorDialog — seed the error fields, drive OnVideoError down the dialog path, return the dialog's
' message + title. ' message + title.
function TestPlaybackErrorDialog(errorFields as object) as object function TestPlaybackErrorDialog(errorFields as object) as object
@@ -189,6 +204,8 @@ function TestSnapshot() as object
autoplay: m.top.autoplayAfterSeek autoplay: m.top.autoplayAfterSeek
bifVisible: m.bifDisplay.visible bifVisible: m.bifDisplay.visible
chromeShown: (m.chromeMode = ChromeMode.Shown or m.chromeMode = ChromeMode.FadingIn) chromeShown: (m.chromeMode = ChromeMode.Shown or m.chromeMode = ChromeMode.FadingIn)
chromeFadingOut: (m.chromeMode = ChromeMode.FadingOut)
autoHideControl: m.autoHide.control
suppressCaptions: m.top.suppressCaptions suppressCaptions: m.top.suppressCaptions
focusTarget: m.focusTarget focusTarget: m.focusTarget
focusedButton: m.focusedButton focusedButton: m.focusedButton
@@ -53,6 +53,8 @@
<function name="TestSetControl" /> <function name="TestSetControl" />
<function name="TestSetLive" /> <function name="TestSetLive" />
<function name="TestFireLiveBadgeHold" /> <function name="TestFireLiveBadgeHold" />
<function name="TestKillAutoHide" />
<function name="TestFinishChromeFadeOut" />
<function name="TestPlaybackErrorDialog" /> <function name="TestPlaybackErrorDialog" />
<function name="TestCoordinatorFields" /> <function name="TestCoordinatorFields" />
</interface> </interface>
@@ -191,6 +191,132 @@ namespace Tests
m.assertTrue(m.Snap().chromeShown, "Up revealed the chrome") m.assertTrue(m.Snap().chromeShown, "Up revealed the chrome")
end function end function
' =========================================================================================
' Back ladder — a transport active > the chrome visible in any form > nothing left to dismiss.
' =========================================================================================
' Rung 1: a transport active -> Back cancels it and KEEPS WATCHING (never exits). VOD stays exactly
' where the freeze put it: PAUSED (no resume intent — the settled cancel/commit asymmetry). Also
' re-arms auto-hide: OnAutoHideFire no-ops without rearming itself (repeat=false) while a transport is
' active, so a scrub that outlasted the 5s timer leaves it dead — TestKillAutoHide models that fired
' state first, otherwise the "start" read here would pass even with the rearm deleted (a fired Timer
' still READS control="start").
@it("Back while a VOD transport is active cancels it (rung 1): keeps watching, stays paused, chrome stays up, auto-hide is rearmed")
function _()
m.top.callFunc("TestKey", RemoteKeys.Left, true) ' transport-key reveal + freeze the scrub
m.top.callFunc("TestKey", RemoteKeys.Left, false)
mid = m.Snap()
m.assertEqual(mid.transportMode, TransportController.Mode.Scrub)
m.assertTrue(mid.chromeShown)
m.assertEqual(mid.control, VideoControl.Pause, "the scrub froze the device")
m.top.callFunc("TestKillAutoHide") ' the 5s auto-hide fired mid-scrub: timer dead
m.top.callFunc("TestKey", RemoteKeys.Back, true)
after = m.Snap()
m.assertEqual(after.transportMode, TransportController.Mode.Idle, "Back cancelled the transport")
m.assertFalse(m.top.videoQueue.closePlayer, "Back must NOT exit while a transport was active -- it only cancels")
m.assertEqual(after.control, VideoControl.Pause, "a VOD cancel emits NO intent: the device stays where the freeze put it (paused)")
m.assertTrue(after.chromeShown, "the HUD stays up; only the transport is cancelled")
m.assertEqual(after.autoHideControl, "start", "auto-hide is rearmed -- else the chrome would be stuck shown (the timer died mid-transport)")
end function
' Rung 1 on LIVE: cancel also RESUMES at the frozen playhead, without a seek. Idle-paused live is a
' dead end (OK only toggles the HUD on live, and the paused playhead drifts toward the DVR floor
' until the device force-resumes it anyway), so the cancel emits the resume itself.
@it("Back while a live transport is active (rung 1): cancels AND resumes at the frozen playhead, no seek")
function _()
m.top.callFunc("TestSetLive", 43200000) ' 12h stream at the edge, 4h window
seekBefore = m.top.seek
m.top.callFunc("TestKey", RemoteKeys.Left, true) ' rewind: LiveDvr + freeze
m.top.callFunc("TestKey", RemoteKeys.Left, false)
mid = m.Snap()
m.assertEqual(mid.transportMode, TransportController.Mode.LiveDvr)
m.assertEqual(mid.control, VideoControl.Pause, "the live transport froze the device")
m.top.callFunc("TestKey", RemoteKeys.Back, true)
after = m.Snap()
m.assertEqual(after.transportMode, TransportController.Mode.Idle, "Back cancelled the transport")
m.assertFalse(m.top.videoQueue.closePlayer)
m.assertEqual(after.control, VideoControl.Resume, "a LIVE cancel resumes -- idle-paused live has no OK-resume and cannot hold anyway")
m.assertEqual(m.top.seek, seekBefore, "the resume carries NO seek: playback continues from the frozen playhead, still behind the edge")
end function
' Rung 2: idle, chrome shown -> Back dismisses it with the SAME animated fade auto-hide uses
' (HideChrome), not the instant HideChromeNow, and does not exit.
@it("Back while idle with the chrome up dismisses it via the animated fade (rung 2): does not exit")
function _()
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' idle reveal, no transport
mid = m.Snap()
m.assertEqual(mid.transportMode, TransportController.Mode.Idle)
m.assertTrue(mid.chromeShown)
m.top.callFunc("TestKey", RemoteKeys.Back, true)
after = m.Snap()
m.assertFalse(m.top.videoQueue.closePlayer, "Back must NOT exit while the chrome was up -- it only dismisses the HUD")
m.assertTrue(after.chromeFadingOut, "Back used the animated HideChrome fade (matches auto-hide), not the instant HideChromeNow")
end function
' Rung 3: idle, chrome mid fade-out (the user can still SEE it) -> Back is CONSUMED but does nothing:
' the dismissal is already underway, so the fade just keeps running. Only once it completes (modeled
' via TestFinishChromeFadeOut — test time can't wait out the 0.3s) does Back close.
@it("Back while the chrome is fading out no-ops (rung 3): the fade continues, no exit; Back closes only once fully hidden")
function _()
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' reveal...
m.top.callFunc("TestKey", RemoteKeys.Back, true) ' ...dismiss: now fading out
m.assertTrue(m.Snap().chromeFadingOut)
m.top.callFunc("TestKey", RemoteKeys.Back, true)
after = m.Snap()
m.assertFalse(m.top.videoQueue.closePlayer, "a Back while the chrome is still visible must NOT exit")
m.assertTrue(after.chromeFadingOut, "the fade keeps running -- Back neither restarts, completes, nor cancels it")
' the fade completes -> fully hidden -> NOW Back closes.
m.top.callFunc("TestFinishChromeFadeOut")
m.assertFalse(m.Snap().chromeFadingOut)
m.top.callFunc("TestKey", RemoteKeys.Back, true)
m.assertTrue(m.top.videoQueue.closePlayer, "once fully hidden, Back closes")
end function
' Rung 4: idle, chrome fully hidden -> nothing left to dismiss -> close (today's original behavior).
@it("Back while idle with the chrome already hidden closes the player (rung 4, unchanged)")
function _()
m.assertFalse(m.Snap().chromeShown, "starts hidden after setup")
m.top.callFunc("TestKey", RemoteKeys.Back, true)
m.assertTrue(m.top.videoQueue.closePlayer, "nothing left to dismiss -> Back closes")
end function
' The full ladder driven in one sequence: cancel transport -> dismiss chrome -> no-op while fading ->
' close once hidden. Proves the rungs compose correctly across successive presses, not just in isolation.
@it("the full Back ladder in sequence: cancel transport -> dismiss chrome -> no-op while fading -> close once hidden")
function _()
' step 1: transport active -> cancel, keep watching, chrome still up.
m.top.callFunc("TestKey", RemoteKeys.Left, true)
m.top.callFunc("TestKey", RemoteKeys.Left, false)
m.assertEqual(m.Snap().transportMode, TransportController.Mode.Scrub)
m.top.callFunc("TestKey", RemoteKeys.Back, true)
step1 = m.Snap()
m.assertEqual(step1.transportMode, TransportController.Mode.Idle)
m.assertFalse(m.top.videoQueue.closePlayer)
m.assertTrue(step1.chromeShown, "rung 1 leaves the chrome up")
' step 2: idle, chrome still up from rung 1 -> Back dismisses it (animated).
m.top.callFunc("TestKey", RemoteKeys.Back, true)
step2 = m.Snap()
m.assertFalse(m.top.videoQueue.closePlayer)
m.assertTrue(step2.chromeFadingOut, "rung 2 dismisses via the animated fade")
' step 3: still fading out (the user can see it) -> Back is consumed, the fade keeps running.
m.top.callFunc("TestKey", RemoteKeys.Back, true)
step3 = m.Snap()
m.assertFalse(m.top.videoQueue.closePlayer, "rung 3 never exits")
m.assertTrue(step3.chromeFadingOut, "rung 3 lets the fade finish on its own")
' step 4: the fade completes -> chrome fully hidden -> nothing left to dismiss -> close.
m.top.callFunc("TestFinishChromeFadeOut")
m.top.callFunc("TestKey", RemoteKeys.Back, true)
m.assertTrue(m.top.videoQueue.closePlayer, "rung 4: Back closes")
end function
' The point of the bar-default: Left/Right seek and OK pauses with no navigation at all, straight off a ' The point of the bar-default: Left/Right seek and OK pauses with no navigation at all, straight off a
' fresh reveal. Pinned as its own test rather than left as a side effect of the tier round-trip tests. ' fresh reveal. Pinned as its own test rather than left as a side effect of the tier round-trip tests.
@it("a fresh idle reveal defaults focus to the bar: Left/Right seek and OK pauses with no navigation") @it("a fresh idle reveal defaults focus to the bar: Left/Right seek and OK pauses with no navigation")
@@ -424,7 +550,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", "watchTimeMarker", "reportWatchTime", "errorDialogNode", "lastCommitSeq", "lastExitSeq", "lastFinishSeq", "liveAstSeconds", "liveFallbackEdgeMs", "liveFallbackAtSeconds", "liveBadgeHoldActive", "healCount", "tailResolveCount"] for each name in ["onCloseCalled", "ignoreNextFinished", "videoPlayedSuccessfully", "firstFrameSeen", "showFullScreenHint", "repauseAfterSeek", "seekToPercent", "watchTimeMarker", "reportWatchTime", "errorDialogNode", "lastCommitSeq", "lastFinishSeq", "liveAstSeconds", "liveFallbackEdgeMs", "liveFallbackAtSeconds", "liveBadgeHoldActive", "healCount", "tailResolveCount"]
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
@@ -70,6 +70,45 @@ namespace Tests
m.assertEqual(PlayerCoordinatorLogic.OkActionInIdle("paused", true, true), PlayerCoordinatorLogic.OkAction.ToggleChrome) m.assertEqual(PlayerCoordinatorLogic.OkActionInIdle("paused", true, true), PlayerCoordinatorLogic.OkAction.ToggleChrome)
end function end function
' =========================================================================================
' BackActionFor — the Back ladder (P-total over transportMode x chromeMode)
' =========================================================================================
@describe("BackActionFor")
@it("the Back decision is DEFINED and correct over the FULL axis cross-product (transportMode x chromeMode)")
function _()
modes = [TransportController.Mode.Idle, TransportController.Mode.Scrub, TransportController.Mode.Scan, TransportController.Mode.LiveDvr]
chromeModes = [ChromeMode.Hidden, ChromeMode.FadingIn, ChromeMode.Shown, ChromeMode.FadingOut]
for each mode in modes
for each chrome in chromeModes
expected = PlayerCoordinatorLogic.BackAction.CancelTransport
if mode = TransportController.Mode.Idle
if chrome = ChromeMode.Shown or chrome = ChromeMode.FadingIn
expected = PlayerCoordinatorLogic.BackAction.DismissChrome
else if chrome = ChromeMode.FadingOut
expected = PlayerCoordinatorLogic.BackAction.None
else
expected = PlayerCoordinatorLogic.BackAction.Close
end if
end if
got = PlayerCoordinatorLogic.BackActionFor(mode, chrome)
m.assertEqual(got, expected, "mode=" + mode.ToStr() + " chromeMode=" + chrome.ToStr())
end for
end for
end function
@it("any active transport outranks the chrome (cancel wins even while the chrome is shown)")
function _()
m.assertEqual(PlayerCoordinatorLogic.BackActionFor(TransportController.Mode.Scrub, ChromeMode.Shown), PlayerCoordinatorLogic.BackAction.CancelTransport)
m.assertEqual(PlayerCoordinatorLogic.BackActionFor(TransportController.Mode.LiveDvr, ChromeMode.Shown), PlayerCoordinatorLogic.BackAction.CancelTransport)
end function
@it("only a FULLY hidden chrome closes: a chrome mid fade-out consumes the press and lets the fade finish")
function _()
m.assertEqual(PlayerCoordinatorLogic.BackActionFor(TransportController.Mode.Idle, ChromeMode.FadingOut), PlayerCoordinatorLogic.BackAction.None)
m.assertEqual(PlayerCoordinatorLogic.BackActionFor(TransportController.Mode.Idle, ChromeMode.Hidden), PlayerCoordinatorLogic.BackAction.Close)
end function
' ========================================================================================= ' =========================================================================================
' ShouldShowBuffering — mid-stream spinner gate (firstFrame AND idle AND fullscreen) ' ShouldShowBuffering — mid-stream spinner gate (firstFrame AND idle AND fullscreen)
' ========================================================================================= ' =========================================================================================
@@ -150,17 +150,37 @@ namespace Tests
m.assertEqual(m.t.cursorMs, 64000) m.assertEqual(m.t.cursorMs, 64000)
end function end function
@it("cancel (Back) resets to idle and pulses exit, emitting no seek") @it("ResetTransport (Minimize and the other involuntary resets) resets to idle, emitting no seek/resume/exit")
function _() function _()
m.t.HandleCommand(TransportController.Command.Right) m.t.HandleCommand(TransportController.Command.Right)
m.t.TakeVideoIntent() ' drain the freeze m.t.TakeVideoIntent() ' drain the freeze
seqBefore = m.t.exitSeq m.t.ResetTransport()
m.t.Cancel()
m.assertEqual(m.t.transportMode, TransportController.Mode.Idle) m.assertEqual(m.t.transportMode, TransportController.Mode.Idle)
m.assertEqual(m.t.exitSeq, seqBefore + 1)
m.assertInvalid(m.t.TakeVideoIntent()) m.assertInvalid(m.t.TakeVideoIntent())
end function end function
@it("CancelTransport (Back) on VOD resets to idle and emits NOTHING: the device stays where the freeze put it")
function _()
m.t.HandleCommand(TransportController.Command.Right)
m.t.TakeVideoIntent() ' drain the freeze
m.t.CancelTransport()
m.assertEqual(m.t.transportMode, TransportController.Mode.Idle)
m.assertInvalid(m.t.TakeVideoIntent())
end function
@it("CancelTransport (Back) on LIVE resets to idle and emits a RESUME with no seek (playback continues from the frozen playhead)")
function _()
t = m.Live()
t.HandleCommand(TransportController.Command.Left)
m.assertEqual(t.transportMode, TransportController.Mode.LiveDvr)
t.TakeVideoIntent() ' drain the freeze
t.CancelTransport()
m.assertEqual(t.transportMode, TransportController.Mode.Idle)
intent = t.TakeVideoIntent()
m.assertEqual(intent.control, TransportController.Control.Resume)
m.assertFalse(intent.hasSeek, "no seek: the playhead stays where the freeze left it, still behind the edge")
end function
' ========================================================================================= ' =========================================================================================
' SCAN (VOD Fwd/Rev) — free-run / ladder / wrap / flip / commit / clamp / keyUp no-op ' SCAN (VOD Fwd/Rev) — free-run / ladder / wrap / flip / commit / clamp / keyUp no-op
' ========================================================================================= ' =========================================================================================
@@ -277,7 +277,7 @@ namespace Tests
' CONTINUOUS — equivalence-classed by the guard predicates (cursor/edge/duration compares), not enumerated. ' CONTINUOUS — equivalence-classed by the guard predicates (cursor/edge/duration compares), not enumerated.
continuous = ["cursorMs", "positionMs", "durationMs", "edgeMs", "liveOffsetMs", "storyboardStepMs", "replayTargetMs", "dvrWindowMs", "liveMinGapMs", "liveMinCandidateMs"] continuous = ["cursorMs", "positionMs", "durationMs", "edgeMs", "liveOffsetMs", "storyboardStepMs", "replayTargetMs", "dvrWindowMs", "liveMinGapMs", "liveMinCandidateMs"]
' OUTPUT / IO scratch — drained by the coordinator, not state the FSM branches on. ' OUTPUT / IO scratch — drained by the coordinator, not state the FSM branches on.
io = ["videoIntent", "intentSeq", "commitSeq", "exitSeq", "finishSeq", "timerCmdAction", "timerCmdId", "timerCmdDelayMs", "timerCmdRepeat"] io = ["videoIntent", "intentSeq", "commitSeq", "finishSeq", "timerCmdAction", "timerCmdId", "timerCmdDelayMs", "timerCmdRepeat"]
accounted = {} accounted = {}
for each name in axes : accounted[name] = "axis" : end for for each name in axes : accounted[name] = "axis" : end for