From ce3c216d2fcfcdeca057ee65405a50727018d69f Mon Sep 17 00:00:00 2001 From: Santiago Puppo Date: Tue, 21 Apr 2026 18:12:34 -0300 Subject: [PATCH] Added a warning when tracks are being added before player init --- packages/mux-video/src/base.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/mux-video/src/base.ts b/packages/mux-video/src/base.ts index 1c9ac9e0..4db62420 100644 --- a/packages/mux-video/src/base.ts +++ b/packages/mux-video/src/base.ts @@ -696,6 +696,12 @@ export class MuxVideoBaseElement extends CustomVideoElement implements IMuxVideo } async addCuePoints(cuePoints: CuePoint[]) { + if (!this.nativeEl.currentSrc) { + console.warn( + 'addCuePoints() was called before the media element has loaded. ' + + 'Wait for the loadstart event before calling addCuePoints().' + ); + } return addCuePoints(this.nativeEl, cuePoints); } @@ -708,6 +714,12 @@ export class MuxVideoBaseElement extends CustomVideoElement implements IMuxVideo } async addChapters(chapters: Chapter[]) { + if (!this.nativeEl.currentSrc) { + console.warn( + 'addChapters() was called before the media element has loaded. ' + + 'Wait for the loadstart event before calling addChapters().' + ); + } return addChapters(this.nativeEl, chapters); }