You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor/Rename PlaybackObserver to MediaElementMonitor
**TL;DR: This is a code simplification proposal to set a single
interface for all `HTMLMediaElement` interactions, under a class named
`MediaElementMonitor`. This is just a merge of the previous
`PlaybackObserver` module (which monitors playback) and of previously
direct `HTMLMediaElement` access (which would now be avoided in profit
of calling `MediaElementMonitor` methods).**
---
I worked on multiple R&D subjects recently that needed a re-thinking of
how we interact with the media element in the core logic:
- The "preload" work (to preload a content in-memory before playback).
Here the idea was to make most core RxPlayer modules work optionally
"headlessly" during a preloading phase (without an actual media
element to play on), and to then be able to "hot swap" the media
element at any point if the content needed to be actually played -
with the intent of speeding up loading time for future contents.
- The "Core Dump" work (a planned API to output an extensive snapshot
of the RxPlayer state and playback conditions on playback errors - for
debugging, logging and advanced experimental mitigations purposes of
platform issues).
Here I needed to be able to access many media properties at once and
both their current states but also their last pre-error status.
On both of those subjects, I found that passing around both the media
element and a `PlaybackObserver` everywhere was awkward and unnecessary:
the `PlaybackObserver` already contains the media element and has to be
used for some side-effects: e.g. seeking has to go through it.
So I propose here to just define a single interface to the media
element.
The most difficult step has been to know what to name that thing.
Initially I went with `MediaElementInterface`, but it didn't seem to be
really indicative of what 99% of its use is, which is to monitor
playback conditions.
So in the end I just went with `MediaElementMonitor`. Though it also
allows side-effect on the media element (seeking, setting `src`...)
Not everything is simplified yet (there are still places when I rely on
the two), but it's a good first step.
0 commit comments