From 9f322d372d29dd3fc735c2a9d8a52aeb643c6955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Bj=C3=B6rneheim?= Date: Fri, 13 Feb 2026 16:41:08 +0100 Subject: [PATCH] fix: update Shaka Player to use attach() method instead of deprecated constructor pattern Fixes #120 Changes: - Remove video element from Player constructor (deprecated in v4.x) - Add shaka.polyfill.installAll() call in constructor - Update load() method to call attach() before loading source - Make load() method async to properly await attach() and load() This change prevents the deprecation warning: "Player w/ mediaElement has been deprecated and will be removed in v5.0" Following the migration guide from Shaka Player documentation: https://shaka-player-demo.appspot.com/docs/api/tutorial-basic-usage.html Co-Authored-By: Claude Sonnet 4.5 --- packages/core/src/tech/ShakaTech.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/core/src/tech/ShakaTech.ts b/packages/core/src/tech/ShakaTech.ts index 4e73a2f..47475f9 100644 --- a/packages/core/src/tech/ShakaTech.ts +++ b/packages/core/src/tech/ShakaTech.ts @@ -11,7 +11,7 @@ export default class DashPlayer extends BaseTech { constructor(opts: IWebPlayerOptions) { super(opts); shaka.polyfill.installAll(); - this.shakaPlayer = new shaka.Player(this.video); + this.shakaPlayer = new shaka.Player(); const restrictToElementSize = !opts.disablePlayerSizeLevelCap; this.shakaPlayer.configure({ abr: { restrictToElementSize: restrictToElementSize } }); @@ -28,12 +28,15 @@ export default class DashPlayer extends BaseTech { ); } - load(src: string): Promise { + async load(src: string): Promise { super.setDefaultState(); - return this.shakaPlayer.load(src).catch((error) => { + try { + await this.shakaPlayer.attach(this.video); + await this.shakaPlayer.load(src); + } catch (error) { this.handleLoadError(error); throw error; - }); + } } private handleLoadError(error: any): void {