Skip to content

Commit

Permalink
refactor: reorder some lines
Browse files Browse the repository at this point in the history
  • Loading branch information
WofWca committed Nov 25, 2021
1 parent 587fd35 commit 2eeee34
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/content/AllMediaElementsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,17 @@ export default class AllMediaElementsController {
const timeSavedTrackerPromise = new Promise<TimeSavedTracker>(r => resolveTimeSavedTrackerPromise = r);

const elCrossOrigin = this.activeMediaElementSourceIsCrossOrigin = isSourceCrossOrigin(el);
// I believe 'loadstart' might get emited even if the source didn't change (e.g. `el.load()`
// has been called manually), but you pretty much can't change source and begin its playback
// without firing the 'loadstart' event.
// So this is reliable.
const onMaybeSourceChange = () => {
this.activeMediaElementSourceIsCrossOrigin = isSourceCrossOrigin(el);
// TODO perhaps we also need to re-run the controller selection code (which is inside
// `reactToSettingsNewValues` right now)? But what if `createMediaElementSource` has already been
// called? There isn't really a point in switching to the `ALWAYS_SOUNDED` controller in that case,
// is there?
};
// I believe 'loadstart' might get emited even if the source didn't change (e.g. `el.load()`
// has been called manually), but you pretty much can't change source and begin its playback
// without firing the 'loadstart' event.
// So this is reliable.
el.addEventListener('loadstart', onMaybeSourceChange, { passive: true });
this._onDetachFromActiveElementCallbacks.push(() => el.removeEventListener('loadstart', onMaybeSourceChange));

Expand Down

0 comments on commit 2eeee34

Please sign in to comment.