Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7577f89df6 | ||
|
|
b7183f3603 | ||
|
|
acd745c671 | ||
|
|
2ffbbe9361 | ||
|
|
ba5da82c55 | ||
|
|
61abc7c0b9 | ||
|
|
fde5eb53fa |
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,7 +3,7 @@ title=Playlet
|
||||
# Do not update version manually, it is auto updated from package.json
|
||||
major_version=0
|
||||
minor_version=48
|
||||
build_version=00013
|
||||
build_version=00018
|
||||
|
||||
rsg_version=1.3
|
||||
|
||||
@@ -40,7 +40,7 @@ requires_widevine_version=1.0
|
||||
playlet_lib_squashfs_remote_url=https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.squashfs.pkg
|
||||
playlet_lib_zip_remote_url=https://github.com/iBicha/playlet/releases/latest/download/playlet-lib.zip
|
||||
playlet_lib_zip_embedded_url=pkg:/lib/playlet-lib.zip
|
||||
playlet_lib_zip_debug_url=https://gitea.spaghet.io/spaghet/playlet-piped/raw/branch/piped-backend/piped/playlet-lib-1795496523.zip
|
||||
playlet_lib_zip_debug_url=https://gitea.spaghet.io/spaghet/playlet-piped/raw/branch/piped-features/piped/playlet-lib-1795574696.zip
|
||||
|
||||
git_commit_sha=unknown
|
||||
|
||||
|
||||
@@ -264,6 +264,7 @@ namespace PipedToInvidious
|
||||
"adaptiveFormats": []
|
||||
"formatStreams": []
|
||||
"captions": []
|
||||
"qualityLevels": []
|
||||
"relatedVideos": VideosFromPiped(data.relatedStreams)
|
||||
"recommendedVideos": VideosFromPiped(data.relatedStreams)
|
||||
"storyboards": []
|
||||
@@ -300,6 +301,11 @@ namespace PipedToInvidious
|
||||
end for
|
||||
end if
|
||||
|
||||
' Quality ladder for the player's quality control: the heights the
|
||||
' backend actually serves, highest first, deduplicated.
|
||||
' (The router fills this from the HLS master manifest - videoStreams
|
||||
' is unreliable: often empty or short of the master's top rungs.)
|
||||
|
||||
for each caption in EnsureArray(data.subtitles)
|
||||
if type(caption) <> "roAssociativeArray"
|
||||
continue for
|
||||
@@ -571,6 +577,66 @@ namespace PipedToInvidious
|
||||
return LCase(q)
|
||||
end function
|
||||
|
||||
' Lowercase "1080p"-style ladder parsed from an HLS master manifest:
|
||||
' every #EXT-X-STREAM-INF RESOLUTION= height, deduplicated, highest
|
||||
' first. This is the ladder the /api/hls quality filter actually slices,
|
||||
' so it is the only honest source for the picker.
|
||||
function QualityLevelsFromHlsMaster(manifest as dynamic) as object
|
||||
if not IsString(manifest) or manifest = ""
|
||||
return []
|
||||
end if
|
||||
|
||||
' Piped masters use CR-only line endings; normalize before splitting.
|
||||
manifest = manifest.Replace(chr(13) + chr(10), chr(10))
|
||||
manifest = manifest.Replace(chr(13), chr(10))
|
||||
|
||||
seen = {}
|
||||
entries = []
|
||||
for each line in manifest.Split(chr(10))
|
||||
if not line.Trim().StartsWith("#EXT-X-STREAM-INF:")
|
||||
continue for
|
||||
end if
|
||||
resolution = StringUtils.GetBetween(line, "RESOLUTION=", ",")
|
||||
if StringUtils.IsNullOrEmpty(resolution)
|
||||
continue for
|
||||
end if
|
||||
parts = resolution.Split("x")
|
||||
if parts.Count() <> 2
|
||||
continue for
|
||||
end if
|
||||
height = Val(parts[1])
|
||||
if height <= 0
|
||||
continue for
|
||||
end if
|
||||
label = `${height}p`
|
||||
if seen.DoesExist(label)
|
||||
continue for
|
||||
end if
|
||||
seen[label] = true
|
||||
entries.push({ "label": label, "height": height })
|
||||
end for
|
||||
|
||||
' Insertion sort by descending height (ladders are tiny)
|
||||
for i = 1 to entries.Count() - 1
|
||||
entry = entries[i]
|
||||
j = i - 1
|
||||
while j >= 0
|
||||
if entries[j].height >= entry.height
|
||||
exit while
|
||||
end if
|
||||
entries[j + 1] = entries[j]
|
||||
j = j - 1
|
||||
end while
|
||||
entries[j + 1] = entry
|
||||
end for
|
||||
|
||||
labels = []
|
||||
for each entry in entries
|
||||
labels.push(entry.label)
|
||||
end for
|
||||
return labels
|
||||
end function
|
||||
|
||||
function MillisToSeconds(millis as dynamic) as integer
|
||||
' NOTE: on this device CDbl() of a boxed roLongInt behaves like a
|
||||
' SINGLE-precision float: 1256453853000 -> truncates to low 32 bits,
|
||||
|
||||
@@ -9,9 +9,11 @@ const SCREEN_CENTER_X = 640
|
||||
const TRACKBAR_RIGHT_X = 1212
|
||||
|
||||
function Init()
|
||||
' Focus order MUST match PlayerCoordinatorLogic.PlayerButton (playPause=0, minimize=1).
|
||||
' Focus order MUST match PlayerCoordinatorLogic.PlayerButton (playPause=0, quality=1, captions=2, minimize=3).
|
||||
m.buttons = [
|
||||
m.top.findNode("PlayPauseButton")
|
||||
m.top.findNode("QualityButton")
|
||||
m.top.findNode("CaptionsButton")
|
||||
m.top.findNode("MinimizeButton")
|
||||
]
|
||||
m.centerCluster = m.top.findNode("CenterCluster")
|
||||
@@ -19,7 +21,7 @@ function Init()
|
||||
LayoutClusters()
|
||||
m.top.buttonCount = m.buttons.Count() ' coordinator reads this to clamp focus
|
||||
|
||||
for each field in ["transportMode", "rowFocused", "focusedIndex", "playing"]
|
||||
for each field in ["transportMode", "rowFocused", "focusedIndex", "playing", "statusText"]
|
||||
m.top.ObserveField(field, FuncName(Repaint))
|
||||
end for
|
||||
m.top.ObserveField("nudge", FuncName(OnNudge))
|
||||
|
||||
@@ -30,11 +30,12 @@ namespace Tests
|
||||
|
||||
@it("exposes its button count and auto-positions the clusters (centered + right-aligned)")
|
||||
function _()
|
||||
m.assertEqual(m.top.buttonCount, 2)
|
||||
' one 42px button per cluster: centered on 640 -> x=619; right-aligned to 1212 -> x=1170. Pins the
|
||||
' ClusterWidth math so a drift in BUTTON_WIDTH/itemSpacings can't silently de-center.
|
||||
m.assertEqual(m.top.buttonCount, 4)
|
||||
' one 42px button in the center cluster (centered on 640 -> x=619); three in the right cluster
|
||||
' (3*42 + 2*20 = 166 wide, right-aligned to 1212 -> x=1046). Pins the ClusterWidth math so a
|
||||
' drift in BUTTON_WIDTH/itemSpacings can't silently de-center.
|
||||
m.assertEqual(m.top.findNode("CenterCluster").translation[0], 619.0)
|
||||
m.assertEqual(m.top.findNode("RightCluster").translation[0], 1170.0)
|
||||
m.assertEqual(m.top.findNode("RightCluster").translation[0], 1046.0)
|
||||
end function
|
||||
|
||||
@describe("virtual-focus highlight")
|
||||
@@ -52,7 +53,7 @@ namespace Tests
|
||||
m.top.focusedIndex = 0
|
||||
m.assertTrue(m.top.findNode("PlayPauseButton").focused)
|
||||
m.assertFalse(m.top.findNode("MinimizeButton").focused)
|
||||
m.top.focusedIndex = 1
|
||||
m.top.focusedIndex = 3
|
||||
m.assertFalse(m.top.findNode("PlayPauseButton").focused)
|
||||
m.assertTrue(m.top.findNode("MinimizeButton").focused)
|
||||
end function
|
||||
@@ -62,7 +63,7 @@ namespace Tests
|
||||
@it("nudge pulses the focused button's animation")
|
||||
function _()
|
||||
m.top.rowFocused = true
|
||||
m.top.focusedIndex = 1
|
||||
m.top.focusedIndex = 3
|
||||
anim = m.top.findNode("MinimizeButton").findNode("nudgeAnim")
|
||||
anim.control = "stop"
|
||||
m.top.nudge = true
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
<field id="focusedIndex" type="integer" value="0" />
|
||||
<field id="playing" type="boolean" value="true" /> <!-- selects the play vs pause icon -->
|
||||
<field id="buttonCount" type="integer" value="0" /> <!-- read-only: set in Init from m.buttons -->
|
||||
<!-- pulse the focused button's scale nudge (a press that couldn't move focus: Left/Right clamped at
|
||||
the row's ends, Up at the top tier). -->
|
||||
<!-- current quality + captions state, shown above the clusters (fed by the coordinator). -->
|
||||
<field id="statusText" type="string" alias="statusLabel.text" />
|
||||
<!-- pulse the focused button's scale nudge: confirms a press that couldn't move focus (Left/Right at the row's end,
|
||||
Up at the top tier). -->
|
||||
<field id="nudge" type="boolean" alwaysNotify="true" />
|
||||
</interface>
|
||||
<children>
|
||||
@@ -29,10 +31,18 @@
|
||||
iconUri="pkg:/images/icons/player/play.png"
|
||||
iconUri2="pkg:/images/icons/player/pause.png" />
|
||||
</Group>
|
||||
<!-- minimize, right-aligned to the trackbar's right edge (x=1212). -->
|
||||
<!-- quality, captions, minimize, right-aligned to the trackbar's right edge (x=1212). -->
|
||||
<Group id="RightCluster">
|
||||
<VideoPlayerButton id="QualityButton"
|
||||
iconUri="pkg:/images/icons/player/quality.png" />
|
||||
<VideoPlayerButton id="CaptionsButton"
|
||||
iconUri="pkg:/images/icons/player/captions.png" />
|
||||
<VideoPlayerButton id="MinimizeButton"
|
||||
iconUri="pkg:/images/icons/player/minimize.png" />
|
||||
</Group>
|
||||
<Label id="statusLabel" translation="[68,522]" width="700" height="28"
|
||||
color="0xFEFEFEFF" horizAlign="left" vertAlign="bottom" wrap="false">
|
||||
<Font role="font" uri="font:SystemFontFile" size="22" />
|
||||
</Label>
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,337 @@
|
||||
import "pkg:/source/utils/CodecCapabilities.bs"
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
' Quality + captions control for the custom player (VideoPlayerDev). A plain
|
||||
' .bs module like SponsorBlockController/TransportController - the coordinator
|
||||
' owns the node and calls into this. Quality switching rebuilds the /api/hls
|
||||
' proxy URL with a different `quality` filter (HlsRouter serves the filtered
|
||||
' ladder) and restarts playback at the saved position; the selection persists
|
||||
' to playback.preferred_quality so the next video starts the same way.
|
||||
' Captions toggle the device's globalCaptionMode and pick a track when the OS
|
||||
' language match finds none.
|
||||
namespace PlaybackControls
|
||||
|
||||
class Controller
|
||||
private top as object
|
||||
private preferences as object
|
||||
' cycle order: auto first, then the backend's ladder high -> low.
|
||||
private qualityCycle as object = ["auto", "1080p", "720p", "480p", "360p", "240p", "144p"]
|
||||
private captionsAvailable as boolean = false
|
||||
' live height of the segment being streamed ("1080p"), shown next to Auto.
|
||||
private liveHeightLabel as string = ""
|
||||
' a quality switch in flight: the URL to swap in once the stop completes.
|
||||
private pendingSwitchUrl as object = invalid
|
||||
private pendingSeekSeconds as float = 0
|
||||
private pendingWasPaused as boolean = false
|
||||
' the picker's virtual cursor while open (-1 = closed)
|
||||
private pickerFocusIndex as integer = -1
|
||||
|
||||
function new(deps as object)
|
||||
m.top = deps.top
|
||||
m.preferences = deps.preferences
|
||||
end function
|
||||
|
||||
' Content-job success: rebuild the cycle from the backend's ladder and
|
||||
' note whether this video has captions at all.
|
||||
function OnContentReady(metadata as object) as void
|
||||
m.liveHeightLabel = ""
|
||||
m.pendingSwitchUrl = invalid
|
||||
|
||||
m.captionsAvailable = false
|
||||
if IsAssociativeArray(metadata)
|
||||
captions = metadata.captions
|
||||
m.captionsAvailable = IsArray(captions) and captions.Count() > 0
|
||||
end if
|
||||
|
||||
levels = invalid
|
||||
if IsAssociativeArray(metadata)
|
||||
levels = metadata.qualityLevels
|
||||
end if
|
||||
|
||||
known = {}
|
||||
for each level in ["2160p", "1440p", "1080p", "720p", "480p", "360p", "240p", "144p"]
|
||||
known[level] = true
|
||||
end for
|
||||
|
||||
cycle = ["auto"]
|
||||
if IsArray(levels) and levels.Count() > 0
|
||||
seen = {}
|
||||
for each level in levels
|
||||
if known.DoesExist(level) and not seen.DoesExist(level)
|
||||
' 1440p/2160p are AV1/VP9-only on YouTube-style backends
|
||||
' (same decoder gate as the Settings QualitySelector).
|
||||
if (level = "1440p" or level = "2160p") and not CodecCapabilities.CanDecodeAv1()
|
||||
continue for
|
||||
end if
|
||||
seen[level] = true
|
||||
cycle.push(level)
|
||||
end if
|
||||
end for
|
||||
else
|
||||
for each level in ["1080p", "720p", "480p", "360p", "240p", "144p"]
|
||||
cycle.push(level)
|
||||
end for
|
||||
end if
|
||||
m.qualityCycle = cycle
|
||||
end function
|
||||
|
||||
' streamingSegment edge: remember the height the player actually chose
|
||||
' so "Auto" can show what it resolved to. Returns true when the label
|
||||
' changed (the coordinator then refreshes the status line).
|
||||
function OnStreamingSegment(segment as object) as boolean
|
||||
if not IsAssociativeArray(segment)
|
||||
return false
|
||||
end if
|
||||
height = 0
|
||||
if IsInt(segment.height)
|
||||
height = segment.height
|
||||
end if
|
||||
if height <= 0
|
||||
return false
|
||||
end if
|
||||
label = `${height}p`
|
||||
if label = m.liveHeightLabel
|
||||
return false
|
||||
end if
|
||||
m.liveHeightLabel = label
|
||||
return true
|
||||
end function
|
||||
|
||||
function CurrentQuality() as string
|
||||
if m.preferences = invalid
|
||||
return "auto"
|
||||
end if
|
||||
value = ValidString(m.preferences["playback.preferred_quality"])
|
||||
if StringUtils.IsNullOrEmpty(value)
|
||||
return "auto"
|
||||
end if
|
||||
return value
|
||||
end function
|
||||
|
||||
function CaptionsOn() as boolean
|
||||
if not m.top.hasField("globalCaptionMode")
|
||||
return false
|
||||
end if
|
||||
return m.top.globalCaptionMode = "On"
|
||||
end function
|
||||
|
||||
function QualityStatus() as string
|
||||
quality = m.CurrentQuality()
|
||||
display = quality
|
||||
if quality = "auto"
|
||||
display = Tr(Locale.Settings.AutoQuality)
|
||||
if not StringUtils.IsNullOrEmpty(m.liveHeightLabel)
|
||||
display = `${display} (${m.liveHeightLabel})`
|
||||
end if
|
||||
end if
|
||||
return Tr(Locale.VideoPlayer.QualityButton).Replace("%1", display)
|
||||
end function
|
||||
|
||||
function CaptionsStatus() as string
|
||||
if not m.captionsAvailable
|
||||
return Tr(Locale.VideoPlayer.CaptionsUnavailableButton)
|
||||
end if
|
||||
if m.CaptionsOn()
|
||||
return Tr(Locale.VideoPlayer.CaptionsOnButton)
|
||||
end if
|
||||
return Tr(Locale.VideoPlayer.CaptionsOffButton)
|
||||
end function
|
||||
|
||||
' One line for the button-row status label.
|
||||
function StatusSummary() as string
|
||||
return m.QualityStatus() + " | " + m.CaptionsStatus()
|
||||
end function
|
||||
|
||||
' Quality button: open the picker list (the coordinator renders it; this holds the cursor).
|
||||
function ActivateQuality() as void
|
||||
m.pickerFocusIndex = m.AppliedIndex()
|
||||
end function
|
||||
|
||||
function EndPicker() as void
|
||||
m.pickerFocusIndex = -1
|
||||
end function
|
||||
|
||||
function PickerOpen() as boolean
|
||||
return m.pickerFocusIndex >= 0
|
||||
end function
|
||||
|
||||
function PickerCycle() as object
|
||||
return m.qualityCycle
|
||||
end function
|
||||
|
||||
' Index of the rung matching the applied preference (auto = 0; a multi-quality value that is not a
|
||||
' single rung shows no applied mark).
|
||||
function AppliedIndex() as integer
|
||||
current = m.CurrentQuality()
|
||||
cycle = m.qualityCycle
|
||||
for i = 0 to cycle.Count() - 1
|
||||
if cycle[i] = current
|
||||
return i
|
||||
end if
|
||||
end for
|
||||
return 0
|
||||
end function
|
||||
|
||||
function PickerFocusedIndex() as integer
|
||||
if m.pickerFocusIndex < 0
|
||||
return 0
|
||||
end if
|
||||
return m.pickerFocusIndex
|
||||
end function
|
||||
|
||||
' Move the virtual cursor; clamped at both ends (a list, not a cycle).
|
||||
function MovePickerFocus(delta as integer) as void
|
||||
if m.pickerFocusIndex < 0
|
||||
return
|
||||
end if
|
||||
nextIndex = m.pickerFocusIndex + delta
|
||||
last = m.qualityCycle.Count() - 1
|
||||
if nextIndex < 0
|
||||
nextIndex = 0
|
||||
else if nextIndex > last
|
||||
nextIndex = last
|
||||
end if
|
||||
m.pickerFocusIndex = nextIndex
|
||||
end function
|
||||
|
||||
' OK on an open picker: returns the rung under the cursor ("" = not open).
|
||||
function ConfirmPicker() as string
|
||||
if m.pickerFocusIndex < 0
|
||||
return ""
|
||||
end if
|
||||
return ValidString(m.qualityCycle[m.pickerFocusIndex])
|
||||
end function
|
||||
|
||||
function ApplyQuality(quality as string) as void
|
||||
content = m.top.content
|
||||
if content = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
' The quality filter is always the last query param (VideoContentJob
|
||||
' appends it); strip it from the current URL, then re-apply the pick.
|
||||
urlParts = ValidString(content.url).Split("&quality=")
|
||||
baseUrl = urlParts[0]
|
||||
targetUrl = baseUrl
|
||||
if quality <> "auto"
|
||||
targetUrl = baseUrl + "&quality=" + quality
|
||||
end if
|
||||
|
||||
' Keep the retry-fallback list consistent: register the new URL and
|
||||
' point the index at it, so a later error walks off the end instead
|
||||
' of replaying stale quality variants. (Field reads return a copy of
|
||||
' the array, so the whole list is written back.)
|
||||
urls = content.playletStreamUrls
|
||||
if IsArray(urls)
|
||||
foundIndex = -1
|
||||
for i = 0 to urls.Count() - 1
|
||||
if urls[i] = targetUrl
|
||||
foundIndex = i
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
if foundIndex = -1
|
||||
urls.push(targetUrl)
|
||||
foundIndex = urls.Count() - 1
|
||||
content.playletStreamUrls = urls
|
||||
end if
|
||||
content.playletStreamUrlIndex = foundIndex
|
||||
end if
|
||||
|
||||
' Persist so the next video starts at this quality.
|
||||
if m.preferences <> invalid
|
||||
m.preferences["playback.preferred_quality"] = quality
|
||||
end if
|
||||
|
||||
state = m.top.state
|
||||
position = m.top.position
|
||||
if state = "playing" or state = "buffering" or state = "paused"
|
||||
m.pendingSwitchUrl = targetUrl
|
||||
m.pendingSeekSeconds = position
|
||||
m.pendingWasPaused = state = "paused"
|
||||
' asyncStopSemantics: the swap happens on the "stopped" edge
|
||||
' (ResumeIfPending, called by the coordinator).
|
||||
m.top.control = "stop"
|
||||
else
|
||||
' idle device: swap directly. A seek written before control=play is
|
||||
' the start position (see the error-retry path).
|
||||
m.pendingWasPaused = false
|
||||
content.url = targetUrl
|
||||
m.SeekForResume(content, position)
|
||||
m.top.control = "play"
|
||||
end if
|
||||
|
||||
LogInfo("Quality switch ->", quality, "url=", targetUrl)
|
||||
end function
|
||||
|
||||
' Called from the coordinator's state handler on the "stopped" edge of a
|
||||
' pending switch. Returns true when it resumed (the coordinator then
|
||||
' restores the paused state via WasPaused()).
|
||||
function ResumeIfPending() as boolean
|
||||
if m.pendingSwitchUrl = invalid
|
||||
return false
|
||||
end if
|
||||
|
||||
content = m.top.content
|
||||
content.url = m.pendingSwitchUrl
|
||||
m.pendingSwitchUrl = invalid
|
||||
|
||||
m.SeekForResume(content, m.pendingSeekSeconds)
|
||||
m.top.control = "play"
|
||||
return true
|
||||
end function
|
||||
|
||||
function SeekForResume(content as object, positionSeconds as float) as void
|
||||
if content <> invalid and content.Live = true
|
||||
m.top.seek = 999999
|
||||
else if positionSeconds > 0
|
||||
m.top.seek = positionSeconds
|
||||
end if
|
||||
end function
|
||||
|
||||
function SwitchPending() as boolean
|
||||
return m.pendingSwitchUrl <> invalid
|
||||
end function
|
||||
|
||||
' True when the switch started from a paused video: the coordinator sets
|
||||
' repauseAfterSeek so the resumed playback re-pauses on its first edge.
|
||||
function WasPaused() as boolean
|
||||
return m.pendingWasPaused
|
||||
end function
|
||||
|
||||
' Captions button: toggle the device caption mode. When turning on and
|
||||
' the OS language preference matched no track, fall back to the first
|
||||
' track the backend offered.
|
||||
function ActivateCaptions() as void
|
||||
if not m.captionsAvailable or not m.top.hasField("globalCaptionMode")
|
||||
return
|
||||
end if
|
||||
|
||||
if m.CaptionsOn()
|
||||
m.top.globalCaptionMode = "Off"
|
||||
else
|
||||
m.top.globalCaptionMode = "On"
|
||||
|
||||
current = ""
|
||||
if m.top.hasField("currentSubtitleTrack")
|
||||
current = ValidString(m.top.currentSubtitleTrack)
|
||||
end if
|
||||
if StringUtils.IsNullOrEmpty(current) and m.top.hasField("availableSubtitleTracks")
|
||||
tracks = m.top.availableSubtitleTracks
|
||||
if IsArray(tracks) and tracks.Count() > 0
|
||||
firstTrack = ValidString(tracks[0].TrackName)
|
||||
if firstTrack <> ""
|
||||
m.top.subtitleTrack = firstTrack
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
|
||||
LogInfo("Captions ->", m.top.globalCaptionMode)
|
||||
end function
|
||||
|
||||
end class
|
||||
end namespace
|
||||
@@ -48,7 +48,9 @@ namespace PlayerCoordinatorLogic
|
||||
' (m.buttons / its buttonCount field) — there is no separate count constant to keep in sync.
|
||||
enum PlayerButton
|
||||
PlayPause = 0
|
||||
Minimize = 1
|
||||
Quality = 1
|
||||
Captions = 2
|
||||
Minimize = 3
|
||||
end enum
|
||||
|
||||
' The two focus targets above/at the trackbar: the bar itself (Left/Right scrub, the cursor grows) and the
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
' Pure projection of the picker's input fields (no keys, no focus: the coordinator owns both, same
|
||||
' contract as ButtonRow). Rebuilds the row Labels when `qualities` changes; slides the focus bar and
|
||||
' repaints the row colors/bullets on every focusedIndex/appliedIndex edge.
|
||||
|
||||
const ROW_HEIGHT = 46
|
||||
const PANEL_X = 420 ' (1280 - 440) / 2
|
||||
const PANEL_HEADER_HEIGHT = 82 ' panel top -> first row (header label + gap)
|
||||
const PANEL_BOTTOM_PADDING = 24
|
||||
const BULLET_APPLIED = Chr(9679) + " " ' filled circle (same glyph the live badge uses)
|
||||
const BULLET_NONE = " "
|
||||
|
||||
function Init()
|
||||
m.rows = m.top.findNode("rows")
|
||||
m.focusBar = m.top.findNode("focusBar")
|
||||
m.rowLabels = []
|
||||
end function
|
||||
|
||||
function OnQualitiesChange() as void
|
||||
while m.rows.getChildCount() > 1
|
||||
m.rows.removeChildIndex(m.rows.getChildCount() - 1)
|
||||
end while
|
||||
|
||||
m.rowLabels = []
|
||||
for each quality in ValidArray(m.top.qualities)
|
||||
label = m.rows.CreateChild("Label")
|
||||
label.width = 368
|
||||
label.height = ROW_HEIGHT
|
||||
label.vertAlign = "center"
|
||||
label.horizAlign = "left"
|
||||
label.translation = [0, (m.rowLabels.Count() + 1) * ROW_HEIGHT - ROW_HEIGHT]
|
||||
m.rowLabels.push(label)
|
||||
end for
|
||||
|
||||
' grow the panel to the row count (the 9-rung AV1 ladder would overflow a fixed height)
|
||||
' and re-center it on screen.
|
||||
panel = m.top.findNode("panel")
|
||||
panelHeight = PANEL_HEADER_HEIGHT + m.rowLabels.Count() * ROW_HEIGHT + PANEL_BOTTOM_PADDING
|
||||
panel.height = panelHeight
|
||||
panel.translation = [PANEL_X, (720 - panelHeight) / 2]
|
||||
|
||||
OnRedraw()
|
||||
end function
|
||||
|
||||
function OnRedraw() as void
|
||||
focusedIndex = ValidInt(m.top.focusedIndex)
|
||||
appliedIndex = ValidInt(m.top.appliedIndex)
|
||||
count = m.rowLabels.Count()
|
||||
if count = 0
|
||||
return
|
||||
end if
|
||||
|
||||
m.focusBar.translation = [0, focusedIndex * ROW_HEIGHT]
|
||||
m.focusBar.visible = focusedIndex >= 0 and focusedIndex < count
|
||||
|
||||
for i = 0 to count - 1
|
||||
label = m.rowLabels[i]
|
||||
text = ValidString(m.top.qualities[i])
|
||||
if text = "auto"
|
||||
text = Tr(Locale.Settings.AutoQuality)
|
||||
end if
|
||||
if i = appliedIndex
|
||||
text = BULLET_APPLIED + text
|
||||
else
|
||||
text = BULLET_NONE + text
|
||||
end if
|
||||
|
||||
label.text = text
|
||||
if i = focusedIndex
|
||||
label.color = "#181818FF"
|
||||
label.font = "font:SmallestBoldSystemFont"
|
||||
else
|
||||
label.color = "#EBEBEBFF"
|
||||
label.font = "font:SmallestSystemFont"
|
||||
end if
|
||||
end for
|
||||
end function
|
||||
@@ -0,0 +1,26 @@
|
||||
<component name="QualityPicker" extends="Group">
|
||||
<!-- Modal quality list drawn over the video (sibling of Chrome, so the chrome fade never hides it and
|
||||
it paints above the video). Virtual focus like ButtonRow: real focus stays on the Video node, the
|
||||
coordinator routes keys and drives focusedIndex; this node is a pure projection of
|
||||
qualities/appliedIndex/focusedIndex. -->
|
||||
<interface>
|
||||
<field id="qualities" type="array" onChange="OnQualitiesChange" />
|
||||
<field id="headerText" type="string" alias="headerLabel.text" />
|
||||
<field id="appliedIndex" type="integer" value="-1" onChange="OnRedraw" alwaysNotify="true" />
|
||||
<field id="focusedIndex" type="integer" value="0" onChange="OnRedraw" alwaysNotify="true" />
|
||||
</interface>
|
||||
<children>
|
||||
<Rectangle id="scrim" width="1280" height="720" color="#000000" opacity="0.55" />
|
||||
<Rectangle id="panel" width="440" height="472" translation="[420,124]" color="#242424">
|
||||
<Label id="headerLabel" translation="[36,24]" width="368" height="34"
|
||||
color="#FEFEFEFF" horizAlign="left" vertAlign="top">
|
||||
<Font role="font" uri="font:BoldSystemFontFile" size="26" />
|
||||
</Label>
|
||||
<Group id="rows" translation="[36,82]">
|
||||
<!-- slides under the focused row; painted first, the Labels are its siblings after -->
|
||||
<Poster id="focusBar" width="368" height="46"
|
||||
uri="pkg:/images/white.$$RES$$.9.png" opacity="0.92" visible="false" />
|
||||
</Group>
|
||||
</Rectangle>
|
||||
</children>
|
||||
</component>
|
||||
@@ -5,6 +5,7 @@ import "pkg:/components/JobSystem/JobSystem.bs"
|
||||
import "pkg:/components/Services/Innertube/Constants.bs"
|
||||
import "pkg:/components/VideoPlayer/Lounge.bs"
|
||||
import "pkg:/components/VideoPlayerDev/ErrorDialogController.bs"
|
||||
import "pkg:/components/VideoPlayerDev/PlaybackControls.bs"
|
||||
import "pkg:/components/VideoPlayerDev/PlaybackTelemetry.bs"
|
||||
import "pkg:/components/VideoPlayerDev/PlayerCoordinatorLogic.bs"
|
||||
import "pkg:/components/VideoPlayerDev/SponsorBlockController.bs"
|
||||
@@ -68,6 +69,8 @@ function Initialize()
|
||||
m.showFullScreenHint = false
|
||||
m.focusTarget = PlayerCoordinatorLogic.FocusTarget.Bar
|
||||
m.focusedButton = 0
|
||||
' telemetry's streamingSegment one-shot consumed (we re-arm the observer for the quality label).
|
||||
m.streamingSegmentTelemetryDone = false
|
||||
m.armedTimerId = TransportController.Timer.None ' which module timer the single transportTimer holds
|
||||
m.lastCommitSeq = 0
|
||||
m.lastFinishSeq = 0
|
||||
@@ -93,6 +96,7 @@ function Initialize()
|
||||
m.spinner = m.top.findNode("spinner")
|
||||
m.largePause = m.top.findNode("largePause")
|
||||
m.buttonRow = m.top.findNode("buttonRow")
|
||||
m.qualityPicker = m.top.findNode("qualityPicker")
|
||||
m.fullScreenHint = m.top.findNode("fullScreenHint")
|
||||
|
||||
m.autoHide = m.top.findNode("autoHide")
|
||||
@@ -137,6 +141,12 @@ function OnNodeReady()
|
||||
top: m.top
|
||||
})
|
||||
|
||||
' Quality + captions buttons in the chrome (same module pattern; reads preferences lazily).
|
||||
m.playbackControls = new PlaybackControls.Controller({
|
||||
preferences: m.top.preferences
|
||||
top: m.top
|
||||
})
|
||||
|
||||
' enableUI=false: the OS draws no chrome; we draw it all from the renderers.
|
||||
m.top.enableUI = false
|
||||
|
||||
@@ -325,6 +335,16 @@ end function
|
||||
' Key router — route intent, hold no behavior.
|
||||
'===============================================================================
|
||||
function OnKeyEvent(key as string, press as boolean) as boolean
|
||||
' The quality picker is modal: while it is open it owns every key (Up/Down move the cursor, OK
|
||||
' selects, Back cancels, the rest are swallowed) and the SponsorBlock skip notice must not steal OK.
|
||||
' Releases are swallowed too: a Left/Right up with no down-scrub in flight must not reach the transport.
|
||||
if m.playbackControls.PickerOpen()
|
||||
if press
|
||||
return HandleQualityPickerKey(key)
|
||||
end if
|
||||
return true
|
||||
end if
|
||||
|
||||
' The SponsorBlock manual-skip notice outranks the focus tiers: while it is armed and on screen, OK does
|
||||
' what the notice says (skip) no matter which tier holds focus, and Back dismisses the notice (the escape
|
||||
' hatch for "I don't want to skip") instead of acting on the player.
|
||||
@@ -549,6 +569,12 @@ end function
|
||||
function ActivateButton(index as integer) as void
|
||||
if index = PlayerCoordinatorLogic.PlayerButton.PlayPause
|
||||
TogglePlayPause()
|
||||
else if index = PlayerCoordinatorLogic.PlayerButton.Quality
|
||||
OpenQualityPicker()
|
||||
else if index = PlayerCoordinatorLogic.PlayerButton.Captions
|
||||
m.playbackControls.ActivateCaptions()
|
||||
RefreshPlaybackStatus()
|
||||
ShowChrome() ' the label changed under the user's finger; keep the HUD up (re-arms auto-hide)
|
||||
else if index = PlayerCoordinatorLogic.PlayerButton.Minimize
|
||||
MinimizeReset()
|
||||
VideoQueueUtils.ToggleVideoPictureInPicture(m.videoQueue)
|
||||
@@ -556,6 +582,58 @@ function ActivateButton(index as integer) as void
|
||||
SyncFocus()
|
||||
end function
|
||||
|
||||
'-------------------------------------------------------------------------------
|
||||
' Quality picker — modal list over the video (virtual focus: this router owns the
|
||||
' keys; QualityPicker is a pure projection of focusedIndex/appliedIndex/qualities).
|
||||
'-------------------------------------------------------------------------------
|
||||
function OpenQualityPicker() as void
|
||||
m.playbackControls.ActivateQuality()
|
||||
|
||||
m.qualityPicker.qualities = m.playbackControls.PickerCycle()
|
||||
m.qualityPicker.headerText = Tr(Locale.VideoPlayer.QualityPickerTitle)
|
||||
PushQualityPickerView()
|
||||
m.qualityPicker.visible = true
|
||||
' modal look: the HUD goes away under the picker, and auto-hide stays off while it is up.
|
||||
HideChromeNow()
|
||||
end function
|
||||
|
||||
function CloseQualityPicker() as void
|
||||
m.playbackControls.EndPicker()
|
||||
m.qualityPicker.visible = false
|
||||
ShowChrome()
|
||||
end function
|
||||
|
||||
function PushQualityPickerView() as void
|
||||
m.qualityPicker.focusedIndex = m.playbackControls.PickerFocusedIndex()
|
||||
m.qualityPicker.appliedIndex = m.playbackControls.AppliedIndex()
|
||||
end function
|
||||
|
||||
' Keys while the picker is open: the list owns navigation + select, Back cancels,
|
||||
' everything else is swallowed (the video must not scrub under the modal).
|
||||
function HandleQualityPickerKey(key as string) as boolean
|
||||
if key = RemoteKeys.Up
|
||||
m.playbackControls.MovePickerFocus(-1)
|
||||
PushQualityPickerView()
|
||||
return true
|
||||
else if key = RemoteKeys.Down
|
||||
m.playbackControls.MovePickerFocus(1)
|
||||
PushQualityPickerView()
|
||||
return true
|
||||
else if key = RemoteKeys.Ok
|
||||
chosen = m.playbackControls.ConfirmPicker()
|
||||
CloseQualityPicker()
|
||||
if not StringUtils.IsNullOrEmpty(chosen)
|
||||
m.playbackControls.ApplyQuality(chosen)
|
||||
RefreshPlaybackStatus()
|
||||
end if
|
||||
return true
|
||||
else if key = RemoteKeys.Back
|
||||
CloseQualityPicker()
|
||||
return true
|
||||
end if
|
||||
return true ' modal: consume Left/Right/Play/Rev/Fwd/... so nothing leaks to the transport
|
||||
end function
|
||||
|
||||
' Push the focus state to the renderers. The button row highlights its focused button while the BUTTON tier
|
||||
' holds focus; the trackbar's cursor grows while the BAR tier holds focus. Both are gated on the chrome being
|
||||
' up, so nothing reads as focused while the chrome is hidden.
|
||||
@@ -779,6 +857,11 @@ function OnVideoState(event as object) as void
|
||||
if PlayerCoordinatorLogic.ShouldShowBuffering(m.firstFrameSeen, m.transport.transportMode, m.container.fullscreen)
|
||||
m.spinner.mode = SpinMode.Buffering
|
||||
end if
|
||||
else if state = VideoState.Stopped
|
||||
' a quality switch stopped the stream first; swap in the new URL and replay now.
|
||||
if m.playbackControls.ResumeIfPending()
|
||||
m.repauseAfterSeek = m.playbackControls.WasPaused()
|
||||
end if
|
||||
else if state = VideoState.Finished
|
||||
' a retry replay (error -> next stream URL) ends with a "finished" edge we must swallow.
|
||||
if m.ignoreNextFinished
|
||||
@@ -810,8 +893,19 @@ function OnStreamingSegment(event as object) as void
|
||||
if m.onCloseCalled = true
|
||||
return
|
||||
end if
|
||||
if m.playbackTelemetry.OnStreamingSegment(event.getData())
|
||||
segment = event.getData()
|
||||
|
||||
' the quality label tracks the ladder the player actually chose (auto ramps up over time)
|
||||
if m.playbackControls.OnStreamingSegment(segment)
|
||||
RefreshPlaybackStatus()
|
||||
end if
|
||||
|
||||
if not m.streamingSegmentTelemetryDone and m.playbackTelemetry.OnStreamingSegment(segment)
|
||||
m.streamingSegmentTelemetryDone = true
|
||||
' telemetry only wants the first video segment, then unobserves; re-arm so the
|
||||
' quality label keeps seeing edges (telemetry's own call is gated off above).
|
||||
m.top.unobserveField("streamingSegment")
|
||||
m.top.ObserveField("streamingSegment", FuncName(OnStreamingSegment))
|
||||
end if
|
||||
end function
|
||||
|
||||
@@ -1218,6 +1312,10 @@ function OnVideoContentJobDone(event as object) as void
|
||||
LogDebug("queued SponsorBlockSegmentsJob")
|
||||
end if
|
||||
|
||||
' quality ladder + captions availability for the player's Quality/Captions buttons
|
||||
m.playbackControls.OnContentReady(metadata)
|
||||
RefreshPlaybackStatus()
|
||||
|
||||
UpdateOverlayMeta()
|
||||
SeekToInitialPosition(content)
|
||||
PlayAfterPreviousPlayerHasStopped()
|
||||
@@ -1380,6 +1478,11 @@ function UpdateOverlayMeta() as void
|
||||
m.spinner.secondaryTitle = secondaryTitle
|
||||
end function
|
||||
|
||||
' Push the current quality/captions readout onto the button row's status label.
|
||||
function RefreshPlaybackStatus() as void
|
||||
m.buttonRow.statusText = m.playbackControls.StatusSummary()
|
||||
end function
|
||||
|
||||
'-------------------------------------------------------------------------------
|
||||
' Storyboards — sourced from the native Video.thumbnailTiles field (the OS populates it from the DASH image
|
||||
' AdaptationSet; the DASH builder equalizes @bandwidth across levels and orders sharpest-first so the OS
|
||||
|
||||
@@ -121,5 +121,9 @@
|
||||
<!-- Coordinator pulses `trigger` only on an explicit pause-from-playing, `cancel` on resume. Not chrome-gated. -->
|
||||
<LargePause id="largePause" />
|
||||
|
||||
<!-- ===================== QualityPicker (modal; OUTSIDE Chrome, top of the z-order) ===================== -->
|
||||
<!-- Opened by the Quality button; virtual focus driven by the coordinator (see OpenQualityPicker). -->
|
||||
<QualityPicker id="qualityPicker" visible="false" />
|
||||
|
||||
</children>
|
||||
</component>
|
||||
@@ -56,6 +56,9 @@ function TestSetup() as void
|
||||
m.top.appController = createObject("roSGNode", "Node")
|
||||
m.top.webServer = createObject("roSGNode", "Node")
|
||||
m.top.innertube = createObject("roSGNode", "Node")
|
||||
' the quality switch persists its pick here; the stub needs the field to exist (Node drops writes to
|
||||
' unknown fields, which would make CurrentQuality permanently "auto" in tests).
|
||||
m.top.preferences.addField("playback.preferred_quality", "string", false)
|
||||
|
||||
' AutoBind aliases bound interface fields onto m.<name>; do it manually here (coordinator + Lounge read m.*).
|
||||
m.container = m.top.container
|
||||
@@ -237,6 +240,38 @@ function TestPlaybackErrorDialog(errorFields as object) as object
|
||||
return result
|
||||
end function
|
||||
|
||||
' TestSeedPlaybackContent — content + metadata for the quality/captions seam tests: what
|
||||
' OnVideoContentJobDone leaves behind (a loaded content node with the Piped-shaped metadata),
|
||||
' minus the job. Then runs the REAL OnContentReady hook + status refresh.
|
||||
function TestSeedPlaybackContent(qualityLevels as object, captionCount as integer) as void
|
||||
content = CreateObject("roSGNode", "ContentNode")
|
||||
content.addField("videoId", "string", false)
|
||||
content.addField("playletStreamUrls", "array", false)
|
||||
content.addField("playletStreamUrlIndex", "integer", false)
|
||||
content.addField("metadata", "assocarray", false)
|
||||
captions = []
|
||||
for i = 0 to captionCount - 1
|
||||
captions.push({ language_code: "en", label: "English", url: `http://cc/${i}` })
|
||||
end for
|
||||
content.setFields({
|
||||
videoId: "testvideo01"
|
||||
url: "http://127.0.0.1:8888/api/hls?url=http%3A%2F%2Fup%2Fmaster.m3u8&v=testvideo01"
|
||||
playletStreamUrls: ["http://127.0.0.1:8888/api/hls?url=http%3A%2F%2Fup%2Fmaster.m3u8&v=testvideo01"]
|
||||
playletStreamUrlIndex: 0
|
||||
metadata: { videoId: "testvideo01", lengthSeconds: 600, captions: captions, qualityLevels: qualityLevels }
|
||||
})
|
||||
m.top.content = content
|
||||
' the device-side track list the OS would report after the manifest loads; the captions fallback
|
||||
' (no OS language match) picks from here.
|
||||
tracks = []
|
||||
for i = 0 to captionCount - 1
|
||||
tracks.push({ Description: "English", Language: "eng", TrackName: `http://cc/${i}` })
|
||||
end for
|
||||
m.top.availableSubtitleTracks = tracks
|
||||
m.playbackControls.OnContentReady(content.metadata)
|
||||
RefreshPlaybackStatus()
|
||||
end function
|
||||
|
||||
' TestContentJobFailed — the VideoContentJob's failure result, minus the job: runs the REAL OnVideoContentJobDone.
|
||||
function TestContentJobFailed(errorMessage as string) as void
|
||||
OnVideoContentJobDone({
|
||||
@@ -268,6 +303,11 @@ end function
|
||||
|
||||
' TestSnapshot — read the seam state the spec asserts on (brain + the device control the coordinator wrote).
|
||||
function TestSnapshot() as object
|
||||
content = m.top.content
|
||||
contentUrl = ""
|
||||
if content <> invalid
|
||||
contentUrl = ValidString(content.url)
|
||||
end if
|
||||
return {
|
||||
transportMode: m.transport.transportMode
|
||||
seekSettling: m.transport.seekSettling
|
||||
@@ -290,6 +330,14 @@ function TestSnapshot() as object
|
||||
replayPending: m.transport.replayPending
|
||||
transportTimerControl: m.transportTimer.control
|
||||
buttonRowVisible: m.buttonRow.visible
|
||||
buttonRowStatusText: m.buttonRow.statusText
|
||||
captionMode: m.top.globalCaptionMode
|
||||
qualitySwitchPending: m.playbackControls.SwitchPending()
|
||||
pickerVisible: m.qualityPicker.visible
|
||||
pickerFocusedIndex: m.qualityPicker.focusedIndex
|
||||
pickerAppliedIndex: m.qualityPicker.appliedIndex
|
||||
pickerRowCount: m.qualityPicker.findNode("rows").getChildCount() - 1
|
||||
contentUrl: contentUrl
|
||||
barPositionMs: m.trickPlayBar.positionMs
|
||||
spinnerMode: m.spinner.mode
|
||||
brain: TestBrainSnapshot()
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
<field id="playbackSpeed" type="float" value="1.0" />
|
||||
<field id="enableUI" type="boolean" value="true" />
|
||||
<field id="suppressCaptions" type="boolean" />
|
||||
<field id="globalCaptionMode" type="string" value="Off" />
|
||||
<field id="subtitleTrack" type="string" />
|
||||
<field id="currentSubtitleTrack" type="string" />
|
||||
<field id="availableSubtitleTracks" type="array" value="[]" />
|
||||
<field id="asyncStopSemantics" type="boolean" />
|
||||
<field id="notificationInterval" type="float" />
|
||||
<field id="width" type="float" />
|
||||
@@ -64,6 +68,7 @@
|
||||
<function name="TestSetControl" />
|
||||
<function name="TestSetLive" />
|
||||
<function name="TestSeedSponsorBlock" />
|
||||
<function name="TestSeedPlaybackContent" />
|
||||
<function name="TestSeekToInitialPosition" />
|
||||
<function name="TestErrorRetry" />
|
||||
<function name="TestSetContentLoading" />
|
||||
@@ -110,5 +115,6 @@
|
||||
</Group>
|
||||
<LoadBufferSpinner id="spinner" />
|
||||
<LargePause id="largePause" />
|
||||
<QualityPicker id="qualityPicker" visible="false" />
|
||||
</children>
|
||||
</component>
|
||||
@@ -946,11 +946,13 @@ namespace Tests
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' bar -> buttons tier, play/pause (leftmost)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true) ' clamped at the left end
|
||||
m.assertEqual(m.Snap().nudgeCount, 1)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' -> quality
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' -> captions
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' -> minimize (rightmost)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' clamped at the right end
|
||||
snap = m.Snap()
|
||||
m.assertEqual(snap.nudgeCount, 2)
|
||||
m.assertEqual(snap.focusedButton, 1, "the clamp held the highlight at the end")
|
||||
m.assertEqual(snap.focusedButton, 3, "the clamp held the highlight at the end")
|
||||
end function
|
||||
|
||||
' Down at the bar tier (the bottom, and the default on reveal) is a no-op: consumed, no nudge.
|
||||
@@ -1005,14 +1007,143 @@ namespace Tests
|
||||
function _()
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' reveal -> bar tier (default)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' bar -> buttons tier
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' highlight minimize
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' highlight quality
|
||||
m.assertEqual(m.Snap().focusedButton, 1)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Play, true) ' must pause, not minimize
|
||||
m.top.callFunc("TestKey", RemoteKeys.Play, true) ' must pause, not activate quality
|
||||
snap = m.Snap()
|
||||
m.assertEqual(snap.control, VideoControl.Pause, "Play paused the (playing) video")
|
||||
m.assertEqual(snap.focusedButton, 1, "the highlight is untouched")
|
||||
end function
|
||||
|
||||
' The quality button opens a modal picker over the video (virtual cursor, list not cycle):
|
||||
' the seed's ladder [1080p,720p,480p] renders as auto/1080p/720p/480p rows, cursor starts on the
|
||||
' applied rung (auto), Down moves it, OK applies + arms the stop->play switch, Back cancels.
|
||||
@it("the quality button opens the picker and OK applies the highlighted rung")
|
||||
function _()
|
||||
m.top.callFunc("TestSeedPlaybackContent", ["1080p", "720p", "480p"], 1)
|
||||
m.top.position = 42.0
|
||||
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' reveal -> bar tier
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' bar -> buttons tier
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' highlight quality
|
||||
m.assertEqual(m.Snap().focusedButton, 1)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Ok, true) ' open the picker
|
||||
|
||||
open = m.Snap()
|
||||
m.assertTrue(open.pickerVisible, "the picker opened")
|
||||
m.assertEqual(open.pickerRowCount, 4, "auto + the three seeded rungs")
|
||||
m.assertEqual(open.pickerFocusedIndex, 0, "cursor starts on Auto (the applied rung)")
|
||||
m.assertEqual(open.pickerAppliedIndex, 0, "Auto is marked applied")
|
||||
m.assertFalse(open.chromeShown, "the HUD hides under the modal")
|
||||
|
||||
' the modal swallows transport keys: Left must not scrub
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true)
|
||||
m.assertEqual(m.Snap().transportMode, TransportController.Mode.Idle, "Left swallowed")
|
||||
|
||||
' Down -> 1080p, OK applies: the switch arms (stop first) and the pick persists
|
||||
m.top.callFunc("TestKey", RemoteKeys.Down, true)
|
||||
m.assertEqual(m.Snap().pickerFocusedIndex, 1, "cursor moved to 1080p")
|
||||
m.top.callFunc("TestKey", RemoteKeys.Ok, true)
|
||||
|
||||
snap = m.Snap()
|
||||
m.assertFalse(snap.pickerVisible, "the picker closed")
|
||||
m.assertTrue(snap.qualitySwitchPending, "the switch armed")
|
||||
m.assertEqual(snap.control, VideoControl.Stop, "the switch stopped the player")
|
||||
m.assertEqual(m.top.preferences["playback.preferred_quality"], "1080p", "the pick persisted")
|
||||
m.assertTrue(InStr(snap.buttonRowStatusText, "1080p") > 0, "the status line shows the new quality")
|
||||
|
||||
' the device completes the async stop -> the coordinator swaps the url and replays at position
|
||||
m.top.callFunc("TestSetState", VideoState.Stopped)
|
||||
after = m.Snap()
|
||||
m.assertFalse(after.qualitySwitchPending, "the switch drained")
|
||||
m.assertEqual(after.control, VideoControl.Play, "playback resumed on the new url")
|
||||
m.assertTrue(InStr(after.contentUrl, "&quality=1080p") > 0, "the url carries the quality filter")
|
||||
m.assertEqual(m.top.seek, 42.0, "resumed at the saved position")
|
||||
|
||||
' reopen: the cursor lands on the applied rung; Back cancels without switching
|
||||
m.top.callFunc("TestSetState", VideoState.Playing)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Ok, true)
|
||||
reopen = m.Snap()
|
||||
m.assertTrue(reopen.pickerVisible)
|
||||
m.assertEqual(reopen.pickerFocusedIndex, 1, "cursor reopens on 1080p")
|
||||
m.assertEqual(reopen.pickerAppliedIndex, 1, "1080p is marked applied")
|
||||
m.top.callFunc("TestKey", RemoteKeys.Back, true)
|
||||
cancelled = m.Snap()
|
||||
m.assertFalse(cancelled.pickerVisible, "Back closed the picker")
|
||||
m.assertFalse(cancelled.qualitySwitchPending, "Back applied nothing")
|
||||
m.assertEqual(m.top.preferences["playback.preferred_quality"], "1080p", "the pick unchanged")
|
||||
|
||||
' clamps: Up at the top rung stays on Auto (index 0), not a wrap
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Ok, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' 1080p -> auto
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' clamped at auto
|
||||
m.assertEqual(m.Snap().pickerFocusedIndex, 0, "the cursor clamps at the top")
|
||||
m.top.callFunc("TestKey", RemoteKeys.Back, true)
|
||||
end function
|
||||
|
||||
' The captions button (index 2): toggles globalCaptionMode; it is reported unavailable when the
|
||||
' video has no captions (the coordinator still routes the press; the module no-ops).
|
||||
@it("the captions button toggles the device caption mode")
|
||||
function _()
|
||||
m.top.callFunc("TestSeedPlaybackContent", ["1080p"], 2)
|
||||
m.top.callFunc("TestSetState", VideoState.Playing)
|
||||
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' reveal -> bar tier
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' bar -> buttons tier
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' quality
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' captions
|
||||
m.assertEqual(m.Snap().focusedButton, 2)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Ok, true)
|
||||
|
||||
snap = m.Snap()
|
||||
m.assertEqual(snap.captionMode, "On", "captions turned on")
|
||||
m.assertTrue(InStr(snap.buttonRowStatusText, "On") > 0, "the status line shows Captions: On")
|
||||
|
||||
' the OS language pref matched nothing -> the module fell back to the first offered track.
|
||||
m.assertEqual(m.top.subtitleTrack, "http://cc/0", "fell back to the first track")
|
||||
|
||||
m.top.callFunc("TestKey", RemoteKeys.Ok, true) ' toggle again
|
||||
m.assertEqual(m.Snap().captionMode, "Off", "captions turned off")
|
||||
end function
|
||||
|
||||
' No captions on this video: the toggle is inert and the status line says N/A.
|
||||
@it("the captions button is a no-op when the video has no captions")
|
||||
function _()
|
||||
m.top.callFunc("TestSeedPlaybackContent", ["1080p"], 0)
|
||||
m.top.callFunc("TestSetState", VideoState.Playing)
|
||||
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Ok, true)
|
||||
|
||||
snap = m.Snap()
|
||||
m.assertEqual(snap.captionMode, "Off", "the mode never moved")
|
||||
m.assertTrue(InStr(snap.buttonRowStatusText, "N/A") > 0, "the status line reports N/A")
|
||||
end function
|
||||
|
||||
' The status line reflects the live ladder while Auto is selected: a streamingSegment edge updates
|
||||
' the parenthetical (the auto-ramp readout the user asked for).
|
||||
@it("the status line shows the auto-resolved height from streamingSegment")
|
||||
function _()
|
||||
m.top.callFunc("TestSeedPlaybackContent", ["1080p", "720p"], 0)
|
||||
m.top.callFunc("TestSetState", VideoState.Playing)
|
||||
|
||||
m.top.streamingSegment = { segType: 0, height: 720, width: 1280 }
|
||||
snap = m.Snap()
|
||||
m.assertTrue(InStr(snap.buttonRowStatusText, "Auto (720p)") > 0, "the auto ramp shows in the status line")
|
||||
|
||||
m.top.streamingSegment = { segType: 0, height: 1080, width: 1920 }
|
||||
m.assertTrue(InStr(m.Snap().buttonRowStatusText, "Auto (1080p)") > 0, "it tracks the ramp up")
|
||||
end function
|
||||
|
||||
' Each arm is asserted: a state that silently failed to arm makes every row that follows vacuous.
|
||||
function ArmRouterState(state as string) as void
|
||||
m.top.callFunc("TestSetup")
|
||||
@@ -1079,11 +1210,11 @@ namespace Tests
|
||||
classified[name] = "dep"
|
||||
end for
|
||||
' controllers (plain .bs class instances).
|
||||
for each name in ["transport", "sponsorblock", "playbackTelemetry"]
|
||||
for each name in ["transport", "sponsorblock", "playbackTelemetry", "playbackControls"]
|
||||
classified[name] = "controller"
|
||||
end for
|
||||
' cached child nodes / timers / animations / reusable helpers (structure, not state).
|
||||
for each name in ["chrome", "titleLabel", "secondaryTitleLabel", "clock", "bifDisplay", "trickPlayBar", "spinner", "largePause", "buttonRow", "fullScreenHint", "autoHide", "transportTimer", "liveBadgeHold", "liveEdgeClock", "fullScreenHintTimer", "chromeFadeIn", "chromeFadeOut", "minimize", "nowDateTime"]
|
||||
for each name in ["chrome", "titleLabel", "secondaryTitleLabel", "clock", "bifDisplay", "trickPlayBar", "spinner", "largePause", "buttonRow", "qualityPicker", "fullScreenHint", "autoHide", "transportTimer", "liveBadgeHold", "liveEdgeClock", "fullScreenHintTimer", "chromeFadeIn", "chromeFadeOut", "minimize", "nowDateTime"]
|
||||
classified[name] = "node"
|
||||
end for
|
||||
' in-flight job handles.
|
||||
@@ -1095,7 +1226,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", "loadingSetSeekMs", "watchTimeMarker", "reportWatchTime", "errorDialogNode", "lastCommitSeq", "lastFinishSeq", "liveAstSeconds", "liveFallbackEdgeMs", "liveFallbackAtSeconds", "liveBadgeHoldActive"]
|
||||
for each name in ["onCloseCalled", "ignoreNextFinished", "videoPlayedSuccessfully", "firstFrameSeen", "showFullScreenHint", "repauseAfterSeek", "loadingSetSeekMs", "watchTimeMarker", "reportWatchTime", "errorDialogNode", "lastCommitSeq", "lastFinishSeq", "liveAstSeconds", "liveFallbackEdgeMs", "liveFallbackAtSeconds", "liveBadgeHoldActive", "streamingSegmentTelemetryDone"]
|
||||
classified[name] = "flag"
|
||||
end for
|
||||
' NOT coordinator state — node-scope + test-environment entries, pinned EXPLICITLY (no hidden
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace Http
|
||||
end function
|
||||
|
||||
function LibBuildTag() as string
|
||||
return "PIPED-LIB-24"
|
||||
return "PIPED-LIB-26"
|
||||
end function
|
||||
|
||||
function FetchJson(path as string, params = invalid as object) as dynamic
|
||||
@@ -680,10 +680,34 @@ namespace Http
|
||||
return true
|
||||
end if
|
||||
|
||||
m.SendJson(response, PipedToInvidious.VideoMetadataFromPiped(data, ValidString(context.videoId)))
|
||||
metadata = PipedToInvidious.VideoMetadataFromPiped(data, ValidString(context.videoId))
|
||||
m.FillQualityLadder(metadata, ValidString(data.hls))
|
||||
m.SendJson(response, metadata)
|
||||
return true
|
||||
end function
|
||||
|
||||
' The picker's ladder must mirror the HLS master's variants (that is what
|
||||
' the /api/hls quality filter slices). videoStreams is unreliable: often
|
||||
' empty or missing the master's top rungs. One extra small-text fetch per
|
||||
' video; on failure the ladder stays empty and the player falls back to
|
||||
' the standard rung list.
|
||||
function FillQualityLadder(metadata as object, masterUrl as string) as void
|
||||
if StringUtils.IsNullOrEmpty(masterUrl) or not IsAssociativeArray(metadata)
|
||||
return
|
||||
end if
|
||||
|
||||
response = HttpClient.Get(masterUrl).Await()
|
||||
if not response.IsSuccess()
|
||||
LogWarn("Piped backend: HLS master fetch failed", response.StatusCode())
|
||||
return
|
||||
end if
|
||||
|
||||
levels = PipedToInvidious.QualityLevelsFromHlsMaster(response.Text())
|
||||
if levels.Count() > 0
|
||||
metadata["qualityLevels"] = levels
|
||||
end if
|
||||
end function
|
||||
|
||||
function GetComments(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 987 B |
@@ -984,6 +984,26 @@
|
||||
<source>Error closing video</source>
|
||||
<translation>Error closing video</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Quality: %1</source>
|
||||
<translation>Quality: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Select quality</source>
|
||||
<translation>Select quality</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Captions: On</source>
|
||||
<translation>Captions: On</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Captions: Off</source>
|
||||
<translation>Captions: Off</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Captions: N/A</source>
|
||||
<translation>Captions: N/A</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Request not sent.</source>
|
||||
<translation>Request not sent.</translation>
|
||||
|
||||
@@ -327,6 +327,11 @@ namespace Locale
|
||||
VideoLoadErrorMessage = "Failed to load video information for %1"
|
||||
ErrorPlayingVideo = "Error playing video %1"
|
||||
ErrorClosingVideo = "Error closing video"
|
||||
QualityButton = "Quality: %1"
|
||||
QualityPickerTitle = "Select quality"
|
||||
CaptionsOnButton = "Captions: On"
|
||||
CaptionsOffButton = "Captions: Off"
|
||||
CaptionsUnavailableButton = "Captions: N/A"
|
||||
end enum
|
||||
|
||||
@locale
|
||||
|
||||
Reference in new issue
Block a user