Commit 5b6b9a4
Give the VideoPress tracker a memory, so its events carry a time again
Reported against the sandbox: every VideoPress event arrived with a current
time and a duration of 0, and no gtm4wp.mediaPlaybackPercentage ever fired.
VideoPress does not report playback the way the other embedded players do. Each
message carries only its own payload:
videopress_timeupdate currentTime / currentTimeMs, NO duration
videopress_durationchange duration / durationMs, NO position
videopress_playing nothing but event + id
videopress_pause nothing but event + id
videopress_ended nothing but event + id
videopress_seeking nothing but event + id
videopress_volumechange nothing but event + id
The tracker read currentTimeMs and durationMs off whichever message was in
hand, so both were absent on every state change and reported as 0. The
percentage path was worse than wrong, it was silent: timeupdate carries no
duration, so the zero-duration guard returned before every milestone, and that
event simply never fired for VideoPress at all.
The tracker now keeps the last reported position and duration per guid and
fills every push from that record. Verified against Automattic's postMessage
documentation and cross-read against two independent consumers, Jetpack's own
player bridge and Sensei's player adapter, which stores the duration in a
dataset attribute for exactly this reason.
Three smaller corrections found while reading the real vocabulary:
* There is no videopress_loadedmetadata, so the ready event never had a
trigger of its own. durationchange is the first moment there is a player
worth describing, so it is the signal now, held to one push per guid because
a quality switch reports the duration again. play, paused and seeked are
kept as tolerated aliases, not names the player is known to send.
* toggle_fullscreen is the one message the player sends WITHOUT the
videopress_ prefix, so the prefix test dropped fullscreen entirely. It is
accepted by name now, after the origin check rather than instead of it, and
reports mediaPlayerEventParam the way the HTML5 tracker does. toggle-source
reports the selected quality level the same way.
* A reported position of 0 is now distinguishable from one not reported at
all, which the record depends on: rewinding to the start must overwrite the
remembered position rather than be discarded as falsy.
Every guid-keyed store in the file is null-prototype. The new record is written
back THROUGH its lookup, so a guid of __proto__ would resolve to
Object.prototype and write a playback position onto every object on the page.
The same key also breaks the shared milestone store, whose first-time test
reads Object.prototype and then calls indexOf on it; a regression test covers
both.
The suite was green throughout because its fixtures put currentTimeMs and
durationMs on every message, a test double more generous than the player. The
fixtures now carry only what each real message carries, and 9 of the tests fail
against the previous tracker.
Registers U109 with the full vocabulary and the payload distribution, both
claims to re-verify, and the note that a generous fixture here is what hid this
for a release cycle. VideoPress ships in this same unreleased version, so the
changelog edits its existing bullet rather than adding a Fixed: entry.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent dd5fefd commit 5b6b9a4
5 files changed
Lines changed: 487 additions & 104 deletions
File tree
- .upstream
- js/frontend
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
| 345 | + | |
345 | 346 | | |
346 | 347 | | |
347 | 348 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
0 commit comments