Skip to content

Commit

Permalink
fix(mux-player): Switch to constants instead of inline strings for Me…
Browse files Browse the repository at this point in the history
…dia Chrome attribute names. Fix name mismatch for props.
  • Loading branch information
cjpillsbury committed Nov 10, 2023
1 parent ff6f247 commit fb193d3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/mux-player/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { globalThis, document } from './polyfills';
import { MediaController } from 'media-chrome';
import { Attributes as MediaControllerAttributes } from 'media-chrome/dist/media-container.js';
import { MediaUIAttributes } from 'media-chrome/dist/constants.js';
import 'media-chrome/dist/experimental/index.js';
import { MediaThemeElement } from 'media-chrome/dist/media-theme-element.js';
import MuxVideoElement, { MediaError, Attributes as MuxVideoAttributes } from '@mux/mux-video';
Expand Down Expand Up @@ -330,7 +332,7 @@ class MuxPlayerElement extends VideoApiElement implements MuxPlayerElement {
this.#setUpThemeAttributes();
this.#setUpErrors();
this.#setUpCaptionsButton();
this.#userInactive = this.mediaController?.hasAttribute('userinactive') ?? true;
this.#userInactive = this.mediaController?.hasAttribute(MediaControllerAttributes.USER_INACTIVE) ?? true;
this.#setUpCaptionsMovement();
// NOTE: Make sure we re-render when stream type changes to ensure other props-driven
// template details get updated appropriately (e.g. thumbnails track) (CJP)
Expand Down Expand Up @@ -566,7 +568,7 @@ class MuxPlayerElement extends VideoApiElement implements MuxPlayerElement {

// this is necessary so that if a cue becomes active while the user is active, we still position it above the control bar
const cuechangeHandler = () => {
toggleLines(selectedTrack, this.mediaController?.hasAttribute('userinactive') ?? false);
toggleLines(selectedTrack, this.mediaController?.hasAttribute(MediaControllerAttributes.USER_INACTIVE) ?? false);

Check warning on line 571 in packages/mux-player/src/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/mux-player/src/index.ts#L571

Added line #L571 was not covered by tests
};

const selectTrack = () => {
Expand Down Expand Up @@ -603,7 +605,7 @@ class MuxPlayerElement extends VideoApiElement implements MuxPlayerElement {
}

this.addEventListener('userinactivechange', () => {
const newUserInactive = this.mediaController?.hasAttribute('userinactive') ?? true;
const newUserInactive = this.mediaController?.hasAttribute(MediaControllerAttributes.USER_INACTIVE) ?? true;

Check warning on line 608 in packages/mux-player/src/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/mux-player/src/index.ts#L608

Added line #L608 was not covered by tests

if (this.#userInactive === newUserInactive) {
return;
Expand Down Expand Up @@ -725,11 +727,11 @@ class MuxPlayerElement extends VideoApiElement implements MuxPlayerElement {
}

get hasPlayed() {
return this.mediaController?.hasAttribute('media-has-played') ?? false;
return this.mediaController?.hasAttribute(MediaUIAttributes.MEDIA_HAS_PLAYED) ?? false;

Check warning on line 730 in packages/mux-player/src/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/mux-player/src/index.ts#L730

Added line #L730 was not covered by tests
}

get inLiveWindow() {
return this.mediaController?.hasAttribute('media-time-is-live');
return this.mediaController?.hasAttribute(MediaUIAttributes.MEDIA_TIME_IS_LIVE);

Check warning on line 734 in packages/mux-player/src/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/mux-player/src/index.ts#L734

Added line #L734 was not covered by tests
}

get _hls(): PlaybackEngine | undefined {
Expand Down

0 comments on commit fb193d3

Please sign in to comment.