0.4.0: quality on the film sites that embed Playerjs - #7
Merged
Merged
Conversation
Playerjs keeps the streaming engine it drives inside a closure, so there is
no hls.js instance to find the way there is elsewhere. What it does answer
is its own question: api('qualities') lists the rungs the site built and
api('quality', label) is the call its own menu makes. That is the whole
adapter, and it is what makes the row work on the run of film sites that
embed this player.
The rung the viewer picked is now remembered in one place, above the
adapters, because the ladder is looked up again every time the sheet opens
and a player that has been given a rung goes back to reporting whatever its
own auto has drifted to. The YouTube adapter kept its own copy of that for
the same reason; it no longer needs one.
0.3.0 said a player keeping its engine in a closure was out of reach. It is out of reach through its engine; it is not out of reach through its own answers, which is how the quality row now works there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Sites that embed Playerjs — a large part of what people actually watch on a phone — now offer their quality ladder in the settings sheet like any other player.
0.3.0 documented this as out of reach: Playerjs keeps its streaming engine inside a closure, so there is no hls.js instance to find. That was true about the engine and too strong about the player. Playerjs answers questions about itself:
api('qualities')→ the rungs the site built, in the site's own words (480p, 720p, 1080p, Авто)api('quality')→ what is playing, as1080pwhen pinned orАвто 720pwhen notapi('quality', label)→ the same call its own menu makesBoth are reads and calls on an object the page already published. No code is injected, nothing is evaluated from a string, and the privacy check still passes with permissions exactly
storageandactiveTab.Also
The rung the viewer picked is now remembered above the adapters instead of inside them. The ladder is looked up again every time the sheet opens, which builds a fresh adapter each time, so the memory was being thrown away — and a player given a rung goes back to reporting whatever its own auto drifted to, which made the chip fall back to Auto a few seconds after a choice. The YouTube adapter carried its own copy of the same workaround and no longer needs one.
Tested on the emulator
AOSP Android 16 / Firefox 153, via
web-ext, on a real film page (uaserials.my → hdvbua.pro embed) and on m.youtube.com:Авто · 1080p · 720p · 480p, auto first then best to worstAuto … 144pladder, 720p sticks after reopeningChecks
eslint+prettier+web-ext lint+ privacy check (28 files, permissions allowlist) + 48 unit tests, all green.