Dev player rewrite (#883)
This commit is contained in:
1 parent
8c11272b92
commit
1ba454cdab
80 files changed
+8405
-921
No files matched your search
@@ -0,0 +1,224 @@
|
||||
import "pkg:/components/VideoPlayerDev/TransportController.bs"
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
' Pure projection of the shared scalar fields onto either the VOD bar or the LIVE bar; decides nothing.
|
||||
' Every input field is observed in Init and repaints on change, except glyph, focused and the SponsorBlock
|
||||
' tint, which update only their own piece.
|
||||
|
||||
const GLYPH_ASSET_BASE = "/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/"
|
||||
|
||||
function Init()
|
||||
m.trackFill = m.top.findNode("trackFill")
|
||||
m.playhead = m.top.findNode("playhead")
|
||||
m.playheadFocus = m.top.findNode("playheadFocus")
|
||||
m.playheadFocusScale = m.top.findNode("playheadFocusScale")
|
||||
m.handle = m.top.findNode("handle")
|
||||
m.scanGlyph = m.top.findNode("scanGlyph")
|
||||
m.currentLabel = m.top.findNode("currentLabel")
|
||||
m.remainingLabel = m.top.findNode("remainingLabel")
|
||||
m.bullet = m.top.findNode("bullet")
|
||||
m.liveLabel = m.top.findNode("liveLabel")
|
||||
|
||||
' translated once: code-assigned strings don't get the automatic XML lookup.
|
||||
m.rewindLiveText = Tr(Locale.VideoPlayer.RewindLiveTv)
|
||||
' the ● LIVE badge is right-aligned to the track end on first show (the translated text width varies by
|
||||
' language — "EN DIRECT" is far wider than "LIVE"); measured lazily, once.
|
||||
m.liveBadgeLaidOut = false
|
||||
|
||||
for each field in ["transportMode", "positionMs", "durationMs", "cursorMs", "isLive", "canRewind", "liveOffsetMs", "atLiveEdge", "forceLiveBadge"]
|
||||
m.top.ObserveField(field, FuncName(Repaint))
|
||||
end for
|
||||
m.top.ObserveField("focused", FuncName(OnFocusChange))
|
||||
m.top.ObserveField("glyph", FuncName(OnGlyph))
|
||||
m.top.ObserveField("sbFillBlend", FuncName(OnSbFillBlend))
|
||||
|
||||
Repaint()
|
||||
end function
|
||||
|
||||
function Repaint() as void
|
||||
if m.top.isLive
|
||||
RenderLiveBar()
|
||||
else
|
||||
RenderVodBar()
|
||||
end if
|
||||
end function
|
||||
|
||||
' --- VOD ------------------------------------------------------------------------------------------------
|
||||
function RenderVodBar() as void
|
||||
transportActive = (m.top.transportMode <> TransportController.Mode.Idle)
|
||||
if transportActive
|
||||
displayMs = m.top.cursorMs
|
||||
else
|
||||
displayMs = m.top.positionMs
|
||||
end if
|
||||
durationMs = m.top.durationMs
|
||||
|
||||
progress = 0.0
|
||||
if durationMs > 0
|
||||
progress = displayMs / durationMs
|
||||
end if
|
||||
if progress < 0
|
||||
progress = 0
|
||||
else if progress > 1
|
||||
progress = 1
|
||||
end if
|
||||
fillW = progress * 1144
|
||||
|
||||
m.trackFill.clippingRect = [0, 0, fillW, 12]
|
||||
PositionPlayhead(fillW)
|
||||
m.currentLabel.text = FormatBarTime(displayMs / 1000.0)
|
||||
m.remainingLabel.text = FormatBarTime((durationMs - displayMs) / 1000.0)
|
||||
|
||||
' Raise the handle while scrubbing so the scanGlyph sits at screen-center over the center tile; rest it
|
||||
' low otherwise (the idle InstantReplay icon rides the resting handle).
|
||||
PositionHandle(transportActive)
|
||||
|
||||
m.bullet.visible = false
|
||||
m.liveLabel.visible = false
|
||||
end function
|
||||
|
||||
' --- LIVE -----------------------------------------------------------------------------------------------
|
||||
function RenderLiveBar() as void
|
||||
transportActive = (m.top.transportMode = TransportController.Mode.LiveDvr)
|
||||
|
||||
showBadge = m.top.atLiveEdge or m.top.forceLiveBadge
|
||||
|
||||
' Fill + playhead are proportional to the cursor's place in the DVR window [0, effEdge], where
|
||||
' effEdge = cursor + offset; at the edge the playhead sits at the right end and the fill clips rightward.
|
||||
effEdge = m.top.cursorMs + m.top.liveOffsetMs
|
||||
frac = 1.0
|
||||
if effEdge > 0
|
||||
frac = m.top.cursorMs / (effEdge * 1.0)
|
||||
end if
|
||||
if frac < 0
|
||||
frac = 0
|
||||
else if frac > 1
|
||||
frac = 1
|
||||
end if
|
||||
' 1136.8679 = the stock OS live bar's at-edge fill clip x, captured from the real player
|
||||
' (trackFill clippingRect={1136.8679, 0, 1144, 12}): the fill stops ~7px short of the 1144 track end,
|
||||
' under the resting playhead cap.
|
||||
clipStart = frac * 1136.8679
|
||||
m.trackFill.clippingRect = [clipStart, 0, 1144, 12]
|
||||
PositionPlayhead(clipStart)
|
||||
|
||||
' Handle raised for the bif while rewinding, resting at the edge otherwise.
|
||||
PositionHandle(transportActive)
|
||||
|
||||
' the rewind hint only when the stream actually rewinds (a buffer-sized DVR window doesn't count).
|
||||
if m.top.canRewind
|
||||
m.currentLabel.text = m.rewindLiveText
|
||||
else
|
||||
m.currentLabel.text = ""
|
||||
end if
|
||||
|
||||
if showBadge
|
||||
m.remainingLabel.text = ""
|
||||
m.bullet.visible = true
|
||||
m.liveLabel.visible = true
|
||||
' pin the badge's RIGHT edge to the track end (1144), bullet 24px left of the text — the same formula
|
||||
' reproduces the captured stock English layout (LIVE ~64px wide -> label at 1080, bullet at 1056).
|
||||
if not m.liveBadgeLaidOut
|
||||
m.liveBadgeLaidOut = true
|
||||
labelW = m.liveLabel.boundingRect().width
|
||||
m.liveLabel.translation = [1144 - labelW, 24]
|
||||
m.bullet.translation = [1144 - labelW - 24, 24]
|
||||
end if
|
||||
else
|
||||
m.remainingLabel.text = FormatBarTime(m.top.liveOffsetMs / 1000.0)
|
||||
m.bullet.visible = false
|
||||
m.liveLabel.visible = false
|
||||
end if
|
||||
end function
|
||||
|
||||
' Raise (screen-center, under the bif) or rest (low) the handle that carries the scanGlyph. The focus
|
||||
' indicator is NOT here — the handle sits at bar-centre, not on the cursor; PositionPlayhead grows the
|
||||
' visible cursor instead.
|
||||
function PositionHandle(raised as boolean) as void
|
||||
if raised
|
||||
m.handle.translation = [547, -54]
|
||||
else
|
||||
m.handle.translation = [547, 22]
|
||||
end if
|
||||
end function
|
||||
|
||||
' Place the playhead dot centred on `centerX` (the fill end = the cursor). Only the translation tracks here;
|
||||
' the focus grow/shrink is the scale animation (OnFocusChange), which scales about the dot's centre so the
|
||||
' two never fight.
|
||||
function PositionPlayhead(centerX as float) as void
|
||||
m.playhead.translation = [centerX - 6, 0]
|
||||
end function
|
||||
|
||||
' The enlarged cursor IS the bar-tier focus indicator: swell half-again on focus, settle back on blur
|
||||
' (the same animation, reversed). stop-then-start so a flip mid-flight restarts in the new direction.
|
||||
function OnFocusChange() as void
|
||||
m.playheadFocusScale.reverse = not m.top.focused
|
||||
m.playheadFocus.control = "stop"
|
||||
m.playheadFocus.control = "start"
|
||||
end function
|
||||
|
||||
' --- glyph swap (handle child) --------------------------------------------------------------------------
|
||||
function OnGlyph() as void
|
||||
name = GlyphAssetName(m.top.glyph)
|
||||
if name = ""
|
||||
m.scanGlyph.visible = false
|
||||
else
|
||||
m.scanGlyph.uri = GLYPH_ASSET_BASE + name + ".png"
|
||||
m.scanGlyph.visible = true
|
||||
end if
|
||||
end function
|
||||
|
||||
function GlyphAssetName(glyph as integer) as string
|
||||
if glyph = TransportController.Glyph.SkipBack
|
||||
return "icon_skipBack"
|
||||
else if glyph = TransportController.Glyph.SkipAhead
|
||||
return "icon_skipAhead"
|
||||
else if glyph = TransportController.Glyph.Ffx1
|
||||
return "icon_FFx1"
|
||||
else if glyph = TransportController.Glyph.Ffx2
|
||||
return "icon_FFx2"
|
||||
else if glyph = TransportController.Glyph.Ffx3
|
||||
return "icon_FFx3"
|
||||
else if glyph = TransportController.Glyph.Rwx1
|
||||
return "icon_RWx1"
|
||||
else if glyph = TransportController.Glyph.Rwx2
|
||||
return "icon_RWx2"
|
||||
else if glyph = TransportController.Glyph.Rwx3
|
||||
return "icon_RWx3"
|
||||
else if glyph = TransportController.Glyph.Replay
|
||||
return "icon_replay"
|
||||
end if
|
||||
return ""
|
||||
end function
|
||||
|
||||
' --- SponsorBlock fill tint -----------------------------------------------------------------------------
|
||||
' A SponsorBlock tint overrides the red fill; an empty (fully transparent) value keeps the red.
|
||||
function OnSbFillBlend() as void
|
||||
blend = m.top.sbFillBlend
|
||||
if blend <> invalid and (blend and 255) <> 0
|
||||
m.trackFill.blendColor = blend
|
||||
end if
|
||||
end function
|
||||
|
||||
' --- time format ----------------------------------------------------------------------------------------
|
||||
' under 1min -> "0:SS"; else "MM:SS"; "H:MM:SS" when >= 1hr.
|
||||
function FormatBarTime(seconds as dynamic) as string
|
||||
if seconds = invalid
|
||||
return "0:00"
|
||||
end if
|
||||
secs = Int(seconds)
|
||||
if secs < 0
|
||||
secs = 0
|
||||
end if
|
||||
h = secs \ 3600
|
||||
mn = (secs \ 60) mod 60
|
||||
s = (secs mod 60).ToStr("%02d")
|
||||
if h > 0
|
||||
return h.ToStr() + ":" + mn.ToStr("%02d") + ":" + s
|
||||
end if
|
||||
if mn = 0
|
||||
return "0:" + s
|
||||
end if
|
||||
return mn.ToStr("%02d") + ":" + s
|
||||
end function
|
||||
@@ -0,0 +1,259 @@
|
||||
' TrickPlayBar @SGNode suite — instantiates JUST the bar (no Video node, no coordinator), sets its scalar
|
||||
' INPUT fields, and asserts the rendered child fields: fill clip width, playhead translation, M:SS labels,
|
||||
' the raised handle while a transport is active, the glyph swap, and the live layout (Rewind live TV / offset
|
||||
' / ● LIVE swap). clippingRect reads back as {x,y,width,height} on the render thread.
|
||||
|
||||
namespace Tests
|
||||
|
||||
@SGNode("TrickPlayBar")
|
||||
@suite
|
||||
class TrickPlayBarTests extends Rooibos.BaseTestSuite
|
||||
|
||||
protected override function beforeEach()
|
||||
' reset to a VOD at rest: 200s video, position 0, idle.
|
||||
m.top.isLive = false
|
||||
m.top.transportMode = TransportController.Mode.Idle
|
||||
m.top.durationMs = 200000
|
||||
m.top.positionMs = 0
|
||||
m.top.cursorMs = 0
|
||||
m.top.glyph = TransportController.Glyph.None
|
||||
m.top.atLiveEdge = true
|
||||
m.top.liveOffsetMs = 0
|
||||
end function
|
||||
|
||||
@describe("TrickPlayBar — VOD projection")
|
||||
|
||||
@it("fills the track to progress and places the playhead at the fill end")
|
||||
function _()
|
||||
m.top.positionMs = 100000 ' 50% of 200s
|
||||
fill = m.top.findNode("trackFill")
|
||||
clip = fill.clippingRect
|
||||
' fillW = 0.5 * 1144 = 572
|
||||
m.assertEqual(clip.width, 572.0)
|
||||
ph = m.top.findNode("playhead")
|
||||
m.assertEqual(ph.translation[0], 566.0) ' fillW - 6
|
||||
end function
|
||||
|
||||
@it("uses the cursor (not position) and raises the handle while scrubbing")
|
||||
function _()
|
||||
m.top.positionMs = 0
|
||||
m.top.transportMode = TransportController.Mode.Scrub
|
||||
m.top.cursorMs = 100000 ' the bar must follow the cursor, not the frozen position
|
||||
fill = m.top.findNode("trackFill")
|
||||
m.assertEqual(fill.clippingRect.width, 572.0)
|
||||
handle = m.top.findNode("handle")
|
||||
m.assertEqual(handle.translation[1], -54.0) ' raised
|
||||
end function
|
||||
|
||||
@it("rests the handle at 22 when idle")
|
||||
function _()
|
||||
m.top.transportMode = TransportController.Mode.Idle
|
||||
handle = m.top.findNode("handle")
|
||||
m.assertEqual(handle.translation[1], 22.0)
|
||||
end function
|
||||
|
||||
@it("animates the playhead (the visible cursor) when the bar tier's focus changes")
|
||||
function _()
|
||||
' the focus indicator is the CURSOR swelling, not the bar-centre handle (which is off the cursor and
|
||||
' never read as one — user bug). The swell is the scale animation, played forward on focus and
|
||||
' reversed on blur; the dot itself stays centred on fillW = 572 throughout.
|
||||
m.top.transportMode = TransportController.Mode.Idle
|
||||
m.top.positionMs = 100000 ' 50% of 200s -> fillW 572
|
||||
ph = m.top.findNode("playhead")
|
||||
anim = m.top.findNode("playheadFocus")
|
||||
interp = m.top.findNode("playheadFocusScale")
|
||||
m.top.focused = false
|
||||
anim.control = "stop"
|
||||
m.assertEqual(ph.translation[0], 566.0) ' 572 - 6, regardless of focus
|
||||
m.top.focused = true
|
||||
m.assertEqual(anim.control, "start")
|
||||
m.assertFalse(interp.reverse) ' forward = grow
|
||||
m.assertEqual(ph.translation[0], 566.0) ' focus scales about the centre, never moves the dot
|
||||
' the resting handle stays put (it is no longer the focus indicator).
|
||||
m.assertEqual(m.top.findNode("handle").width, 50.0)
|
||||
m.top.focused = false ' restore the default (the suite shares one node across tests)
|
||||
m.assertTrue(interp.reverse) ' blur reverses = shrink
|
||||
end function
|
||||
|
||||
@it("keeps the playhead grown while SCRUBBING (the bar is still the focused control)")
|
||||
function _()
|
||||
' regression: the focus-grow must NOT shrink mid-seek — the bar tier still holds focus while you
|
||||
' scrub, and a Repaint (cursor move) must not touch the scale animation.
|
||||
m.top.focused = true
|
||||
anim = m.top.findNode("playheadFocus")
|
||||
interp = m.top.findNode("playheadFocusScale")
|
||||
m.top.positionMs = 0
|
||||
m.top.transportMode = TransportController.Mode.Scrub
|
||||
m.top.cursorMs = 100000 ' the bar follows the cursor (50%) -> fillW 572
|
||||
m.assertEqual(anim.control, "start")
|
||||
m.assertFalse(interp.reverse) ' still grown while scrubbing (no shrink issued by the repaints)
|
||||
m.assertEqual(m.top.findNode("playhead").translation[0], 566.0) ' 572 - 6, tracking the cursor
|
||||
m.assertEqual(m.top.findNode("handle").translation[1], -54.0) ' the handle is still raised for the bif
|
||||
m.top.focused = false ' restore (shared node)
|
||||
m.top.transportMode = TransportController.Mode.Idle
|
||||
end function
|
||||
|
||||
@it("formats current/remaining as M:SS")
|
||||
function _()
|
||||
m.top.positionMs = 65000 ' 1:05
|
||||
m.assertEqual(m.top.findNode("currentLabel").text, "01:05")
|
||||
m.assertEqual(m.top.findNode("remainingLabel").text, "02:15") ' 135s left
|
||||
end function
|
||||
|
||||
@describe("TrickPlayBar — glyph swap (handle child)")
|
||||
|
||||
@it("swaps the scanGlyph uri for skipAhead and hides on none")
|
||||
function _()
|
||||
m.top.glyph = TransportController.Glyph.SkipAhead
|
||||
sg = m.top.findNode("scanGlyph")
|
||||
m.assertTrue(sg.visible)
|
||||
m.assertTrue(sg.uri.EndsWith("icon_skipAhead.png"))
|
||||
m.top.glyph = TransportController.Glyph.Ffx3
|
||||
m.assertTrue(sg.uri.EndsWith("icon_FFx3.png"))
|
||||
m.top.glyph = TransportController.Glyph.None
|
||||
m.assertFalse(sg.visible)
|
||||
end function
|
||||
|
||||
@it("shows the InstantReplay icon in idle, riding the resting handle (stock {547,22})")
|
||||
function _()
|
||||
m.top.transportMode = TransportController.Mode.Idle ' replay returns to idle but flashes the icon
|
||||
m.top.cursorMs = 40000 ' a replay -20s seek -> Repaint runs idle, handle at rest
|
||||
m.top.glyph = TransportController.Glyph.Replay
|
||||
sg = m.top.findNode("scanGlyph")
|
||||
m.assertTrue(sg.visible)
|
||||
m.assertTrue(sg.uri.EndsWith("icon_replay.png"))
|
||||
handle = m.top.findNode("handle")
|
||||
m.assertEqual(handle.translation[1], 22.0) ' rest, NOT raised (icon sits in the resting handle)
|
||||
' toast expiry (glyph -> none) just hides the icon; handle stays at rest
|
||||
m.top.glyph = TransportController.Glyph.None
|
||||
m.assertFalse(sg.visible)
|
||||
m.assertEqual(handle.translation[1], 22.0)
|
||||
end function
|
||||
|
||||
@describe("TrickPlayBar — LIVE projection")
|
||||
|
||||
@it("BEHIND the edge: fill/playhead are PROPORTIONAL to cursor within the DVR window + offset label")
|
||||
function _()
|
||||
m.top.isLive = true
|
||||
m.top.transportMode = TransportController.Mode.LiveDvr
|
||||
m.top.atLiveEdge = false
|
||||
' cursor 90% of the way to the effective edge (cursor 9000, offset 1000 -> effEdge 10000)
|
||||
m.top.cursorMs = 9000
|
||||
m.top.liveOffsetMs = 1000
|
||||
fill = m.top.findNode("trackFill")
|
||||
m.assertTrue(Abs(fill.clippingRect.x - 0.9 * 1136.8679) < 0.5) ' proportional, not pinned
|
||||
m.assertTrue(Abs(m.top.findNode("playhead").translation[0] - (0.9 * 1136.8679 - 6)) < 0.5)
|
||||
m.assertEqual(m.top.findNode("currentLabel").text, Tr(Locale.VideoPlayer.RewindLiveTv))
|
||||
m.assertEqual(m.top.findNode("remainingLabel").text, "0:01")
|
||||
m.assertFalse(m.top.findNode("bullet").visible)
|
||||
m.assertFalse(m.top.findNode("liveLabel").visible)
|
||||
end function
|
||||
|
||||
@it("a NON-rewindable live stream (buffer-sized DVR window) drops the rewind label")
|
||||
function _()
|
||||
m.top.isLive = true
|
||||
m.top.transportMode = TransportController.Mode.Idle
|
||||
m.top.canRewind = false
|
||||
m.assertEqual(m.top.findNode("currentLabel").text, "")
|
||||
' rewindable again (e.g. next content) -> the label returns
|
||||
m.top.canRewind = true
|
||||
m.assertEqual(m.top.findNode("currentLabel").text, Tr(Locale.VideoPlayer.RewindLiveTv))
|
||||
end function
|
||||
|
||||
@it("AT the edge: frac=1 -> playhead at 1130.87 (the exact at-edge stock pin) + ● LIVE")
|
||||
function _()
|
||||
m.top.isLive = true
|
||||
m.top.transportMode = TransportController.Mode.Idle
|
||||
m.top.atLiveEdge = true
|
||||
m.top.cursorMs = 43200000 ' at the edge: offset 0 -> frac 1
|
||||
m.top.liveOffsetMs = 0
|
||||
fill = m.top.findNode("trackFill")
|
||||
m.assertEqual(fill.clippingRect.x, 1136.8679) ' frac 1 -> at-edge max
|
||||
m.assertEqual(m.top.findNode("playhead").translation[0], 1130.8679)
|
||||
m.assertTrue(m.top.findNode("bullet").visible) ' ● LIVE
|
||||
m.assertTrue(m.top.findNode("liveLabel").visible)
|
||||
end function
|
||||
|
||||
@it("1hr back on a 12h stream moves the playhead ~1/12 of the bar (proportional, user A/B)")
|
||||
function _()
|
||||
m.top.isLive = true
|
||||
m.top.transportMode = TransportController.Mode.LiveDvr
|
||||
m.top.atLiveEdge = false
|
||||
m.top.cursorMs = 39600000 ' 11h
|
||||
m.top.liveOffsetMs = 3600000 ' 1h behind -> effEdge 43.2M, frac = 11/12
|
||||
playheadX = m.top.findNode("playhead").translation[0]
|
||||
atEdgeX = 1130.8679
|
||||
' moved back ~1/12 of the 1136.87-wide travel from the edge
|
||||
moved = atEdgeX - playheadX
|
||||
m.assertTrue(moved > 85 and moved < 105) ' ~1136.87/12 ≈ 95px
|
||||
end function
|
||||
|
||||
@it("shows the ● LIVE badge only at the edge")
|
||||
function _()
|
||||
m.top.isLive = true
|
||||
m.top.atLiveEdge = true
|
||||
m.top.liveOffsetMs = 0
|
||||
m.assertTrue(m.top.findNode("bullet").visible)
|
||||
m.assertTrue(m.top.findNode("liveLabel").visible)
|
||||
m.assertEqual(m.top.findNode("remainingLabel").text, "")
|
||||
' the badge styling: red bullet + bold size-30 LIVE. blendColor reads back as a signed 32-bit int.
|
||||
m.AssertBlend(m.top.findNode("bullet").blendColor, &hD53E5AFF)
|
||||
m.assertEqual(m.top.findNode("liveLabel").text, Tr("LIVE"))
|
||||
' the badge is right-aligned to the track end whatever the language ("EN DIRECT" >> "LIVE").
|
||||
lbl = m.top.findNode("liveLabel")
|
||||
m.assertTrue(Abs((lbl.translation[0] + lbl.boundingRect().width) - 1144) < 2, "badge right edge pinned to the track end")
|
||||
m.assertTrue(m.top.findNode("bullet").translation[0] < lbl.translation[0], "bullet sits left of the text")
|
||||
end function
|
||||
|
||||
@it("forceLiveBadge shows ● LIVE even when behind the edge (reveal latch, bug 6)")
|
||||
function _()
|
||||
m.top.isLive = true
|
||||
m.top.atLiveEdge = false
|
||||
m.top.liveOffsetMs = 17000
|
||||
' the reveal latch forces the badge briefly even though we're behind the edge
|
||||
m.top.forceLiveBadge = true
|
||||
m.assertTrue(m.top.findNode("bullet").visible)
|
||||
m.assertTrue(m.top.findNode("liveLabel").visible)
|
||||
m.assertEqual(m.top.findNode("remainingLabel").text, "")
|
||||
' releasing the latch swaps to the offset
|
||||
m.top.forceLiveBadge = false
|
||||
m.assertFalse(m.top.findNode("bullet").visible)
|
||||
m.assertEqual(m.top.findNode("remainingLabel").text, "0:17")
|
||||
end function
|
||||
|
||||
@it("grows the playhead on the LIVE bar too when the bar tier has focus (behind the edge, idle)")
|
||||
function _()
|
||||
' the focus-grow is the same code on both bars, but live is half the player — exercise it here on an
|
||||
' idle-behind-the-edge state (after a pause/commit-behind) where the cursor sits at a non-pinned x.
|
||||
m.top.isLive = true
|
||||
m.top.transportMode = TransportController.Mode.Idle ' idle (not raised) so the playhead can grow
|
||||
m.top.atLiveEdge = false
|
||||
m.top.cursorMs = 9000
|
||||
m.top.liveOffsetMs = 1000 ' effEdge 10000 -> frac 0.9 -> clipStart 1023.18
|
||||
anim = m.top.findNode("playheadFocus")
|
||||
interp = m.top.findNode("playheadFocusScale")
|
||||
m.top.focused = false
|
||||
anim.control = "stop"
|
||||
m.top.focused = true
|
||||
m.assertEqual(anim.control, "start") ' the cursor swells on the live bar as well
|
||||
m.assertFalse(interp.reverse)
|
||||
m.top.focused = false ' restore (the suite shares one node across tests)
|
||||
end function
|
||||
|
||||
@describe("TrickPlayBar — SponsorBlock fill tint")
|
||||
|
||||
@it("applies the SB fill blend over the captured red")
|
||||
function _()
|
||||
m.top.sbFillBlend = "#FF000080"
|
||||
m.AssertBlend(m.top.findNode("trackFill").blendColor, &hFF000080)
|
||||
end function
|
||||
|
||||
' blendColor reads back as a signed 32-bit Integer; coerce the expected hex to the same Integer type.
|
||||
function AssertBlend(actual as dynamic, expectedHex as longinteger) as void
|
||||
expected% = (expectedHex and &hFFFFFFFF)
|
||||
m.assertEqual(actual, expected%)
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
@@ -0,0 +1,74 @@
|
||||
<component name="TrickPlayBar" extends="Group">
|
||||
<!-- A projection of the shared scalar input fields; no outputs. Every input field is observed in code
|
||||
(not onChange) and a change repaints. The scanGlyph is a child of the handle so it paints in front of
|
||||
the bif. Left label = "Rewind live TV" while the stream is rewindable (canRewind); right label =
|
||||
offset M:SS when behind, or "● LIVE" at the edge. -->
|
||||
<interface>
|
||||
<field id="transportMode" type="integer" value="0" /> <!-- selects cursor vs position + raises the handle -->
|
||||
<field id="positionMs" type="integer" value="0" /> <!-- real Video position (used when idle) -->
|
||||
<field id="durationMs" type="integer" value="0" />
|
||||
<field id="cursorMs" type="integer" value="0" /> <!-- transport cursor (used when active) -->
|
||||
<field id="isLive" type="boolean" value="false" />
|
||||
<field id="canRewind" type="boolean" value="true" /> <!-- live only: false (buffer-sized DVR window) drops the rewind label -->
|
||||
<field id="liveOffsetMs" type="integer" value="0" /> <!-- edge - cursor; the right-label M:SS -->
|
||||
<field id="atLiveEdge" type="boolean" value="true" /> <!-- swaps "● LIVE" <-> offset -->
|
||||
|
||||
<field id="glyph" type="integer" value="0" />
|
||||
<field id="forceLiveBadge" type="boolean" value="false" />
|
||||
<field id="focused" type="boolean" value="false" />
|
||||
|
||||
<!-- SponsorBlock (off by default): track image is aliased; fill tint and chapter label drive code/alias. -->
|
||||
<field id="sbBarUri" type="uri" alias="trackBg.uri" />
|
||||
<field id="sbFillBlend" type="color" />
|
||||
<field id="chapterText" type="string" alias="chapterLabel.text" />
|
||||
</interface>
|
||||
<children>
|
||||
<Poster id="trackBg"
|
||||
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/osd_sliderControl_small.9.png"
|
||||
width="1144" height="12" opacity="0.3" loadDisplayMode="noScale" />
|
||||
<!-- same asset tinted red, clipped to progress width in code. -->
|
||||
<Poster id="trackFill"
|
||||
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/osd_sliderControl_small.9.png"
|
||||
width="1144" height="12" blendColor="0xFF1C30FF" clippingRect="[0,0,0,12]" loadDisplayMode="noScale" />
|
||||
<!-- the cursor: a 12px dot that swells half-again while the bar tier holds focus. PositionPlayhead
|
||||
moves it; the grow/shrink animations scale it about its center. -->
|
||||
<Poster id="playhead"
|
||||
uri="pkg:/images/icons/player/white-circle.png"
|
||||
width="12" height="12" scaleRotateCenter="[6, 6]" />
|
||||
<!-- played forward on focus, reversed (interpolator.reverse) on blur. -->
|
||||
<Animation id="playheadFocus" duration="0.1">
|
||||
<Vector2DFieldInterpolator id="playheadFocusScale"
|
||||
key="[ 0.0, 1.0 ]"
|
||||
keyValue="[ [ 1.0, 1.0 ], [ 1.5, 1.5 ] ]"
|
||||
fieldToInterp="playhead.scale" />
|
||||
</Animation>
|
||||
<!-- handle: pinned at bar-center. {547,22} rest, {547,-54} active. -->
|
||||
<Poster id="handle"
|
||||
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/videoProgressBarHandle.9.png"
|
||||
translation="[547, 22]" width="50" height="30" loadDisplayMode="noScale">
|
||||
<Poster id="scanGlyph" visible="false" width="50" height="30" loadDisplayMode="noScale" />
|
||||
</Poster>
|
||||
<!-- left label. VOD: counts up (short). LIVE: the translated "Rewind live TV" — width is generous so
|
||||
no language clips (e.g. the French string); left-aligned, so the extra width paints nothing. -->
|
||||
<Label id="currentLabel" translation="[0, 24]" width="700" height="24"
|
||||
color="0xFEFEFEFF" horizAlign="left" vertAlign="top">
|
||||
<Font role="font" uri="font:SystemFontFile" size="24" />
|
||||
</Label>
|
||||
<!-- right label. VOD: counts down. LIVE: offset M:SS (hidden at edge). -->
|
||||
<Label id="remainingLabel" translation="[1024, 24]" width="120" height="24"
|
||||
color="0xFEFEFEFF" horizAlign="right" vertAlign="top">
|
||||
<Font role="font" uri="font:SystemFontFile" size="24" />
|
||||
</Label>
|
||||
<!-- LIVE bullet: shown only at the edge. -->
|
||||
<Poster id="bullet" visible="false"
|
||||
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/icon_inline_unselected_bullet.webp"
|
||||
translation="[1056, 24]" blendColor="0xD53E5AFF" loadDisplayMode="noScale" />
|
||||
<!-- LIVE badge: shown only at the edge. -->
|
||||
<Label id="liveLabel" visible="false" translation="[1080, 24]" height="30"
|
||||
text="LIVE" color="0xFEFEFEFF" horizAlign="left" vertAlign="top">
|
||||
<Font role="font" uri="font:BoldSystemFontFile" size="30" />
|
||||
</Label>
|
||||
<Label id="chapterLabel" translation="[111, 25]" width="350" height="25"
|
||||
color="0xFEFEFEFF" horizAlign="center" vertAlign="center" font="font:SmallestSystemFont" />
|
||||
</children>
|
||||
</component>
|
||||
Reference in new issue
Block a user