Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/mux-audio/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
getStartDate,
getCurrentPdt,
getEnded,
getCoreReference,
toPlaybackIdParts,
} from '@mux/playback-core';
import type {
Expand Down Expand Up @@ -65,7 +66,6 @@ class MuxAudioElement extends CustomAudioElement implements Partial<MuxMediaProp
return [...AttributeNameValues, ...(CustomAudioElement.observedAttributes ?? [])];
}

#core?: PlaybackCore;
#loadRequested?: Promise<void> | null;
#defaultPlayerInitTime: number | undefined;
#metadata: Readonly<Metadata> = {};
Expand All @@ -77,6 +77,10 @@ class MuxAudioElement extends CustomAudioElement implements Partial<MuxMediaProp
this.#defaultPlayerInitTime = generatePlayerInitTime();
}

get #core(): PlaybackCore | undefined {
return getCoreReference(this.nativeEl);
}

get playerInitTime() {
if (!this.hasAttribute(Attributes.PLAYER_INIT_TIME)) return this.#defaultPlayerInitTime;
return +(this.getAttribute(Attributes.PLAYER_INIT_TIME) as string) as number;
Expand Down Expand Up @@ -464,12 +468,11 @@ class MuxAudioElement extends CustomAudioElement implements Partial<MuxMediaProp
}

load() {
this.#core = initialize(this as Partial<MuxMediaProps>, this.nativeEl, this.#core);
initialize(this as Partial<MuxMediaProps>, this.nativeEl, this.#core);
}

unload() {
teardown(this.nativeEl, this.#core);
this.#core = undefined;
}

attributeChangedCallback(attrName: string, oldValue: string | null, newValue: string | null) {
Expand Down
9 changes: 6 additions & 3 deletions packages/mux-video/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
getChapters,
toPlaybackIdFromSrc,
toPlaybackIdParts,
getCoreReference,
// isMuxVideoSrc,
} from '@mux/playback-core';
import type {
Expand Down Expand Up @@ -103,7 +104,6 @@ export class MuxVideoBaseElement extends CustomVideoElement implements IMuxVideo
return [...AttributeNameValues, ...(CustomVideoElement.observedAttributes ?? [])];
}

#core?: PlaybackCore;
#loadRequested?: Promise<void> | null;
#defaultPlayerInitTime: number | undefined;
#metadata: Metadata = {};
Expand Down Expand Up @@ -173,6 +173,10 @@ export class MuxVideoBaseElement extends CustomVideoElement implements IMuxVideo
});
}

get #core(): PlaybackCore | undefined {
return getCoreReference(this.nativeEl);
}

get preferCmcd() {
return (this.getAttribute(Attributes.PREFER_CMCD) as ValueOf<CmcdTypes>) ?? undefined;
}
Expand Down Expand Up @@ -796,12 +800,11 @@ export class MuxVideoBaseElement extends CustomVideoElement implements IMuxVideo
}

load() {
this.#core = initialize(this as Partial<MuxMediaProps>, this.nativeEl, this.#core);
initialize(this as Partial<MuxMediaProps>, this.nativeEl, this.#core);
}

unload() {
teardown(this.nativeEl, this.#core, this as Partial<MuxMediaProps>);
this.#core = undefined;
}

attributeChangedCallback(attrName: string, oldValue: string | null, newValue: string | null) {
Expand Down
Loading
Loading