Refactor/Rename PlaybackObserver to MediaElementMonitor#1754
Open
peaBerberian wants to merge 1 commit intodevfrom
Open
Refactor/Rename PlaybackObserver to MediaElementMonitor#1754peaBerberian wants to merge 1 commit intodevfrom
PlaybackObserver to MediaElementMonitor#1754peaBerberian wants to merge 1 commit intodevfrom
Conversation
af6e10d to
b7b34ed
Compare
6652566 to
0fa2c02
Compare
0fa2c02 to
d725569
Compare
6cfd206 to
1e55170
Compare
ba8892f to
5833b27
Compare
5833b27 to
950fc06
Compare
950fc06 to
ec1a402
Compare
a42734c to
29372ac
Compare
ec1a402 to
aebf9df
Compare
d4be192 to
9ad6758
Compare
0142e34 to
1fd9df3
Compare
aebf9df to
3a39679
Compare
**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.
3a39679 to
5f6238c
Compare
|
✅ Automated performance checks have passed on commit DetailsPerformance tests 1st run outputNo significative change in performance for tests:
|
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.
TL;DR: This is a code simplification proposal to set a single interface for all
HTMLMediaElementinteractions, under a class namedMediaElementMonitor. This is just a merge of the previousPlaybackObservermodule (which monitors playback) and of previously directHTMLMediaElementaccess (which would now be avoided in profit of callingMediaElementMonitormethods).Based on #1645
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
PlaybackObservereverywhere was awkward and unnecessary: thePlaybackObserveralready 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, settingsrc...)Not everything is simplified yet (there are still places when I rely on the two), but it's a good first step.