From 0368ba96cf2244cfa160de2a548b27a93ca3ece3 Mon Sep 17 00:00:00 2001 From: Theodore Abshire Date: Tue, 6 Feb 2024 11:27:23 -0800 Subject: [PATCH] fix(preload): Only start preload if manager exists Also fixes how demo cards handle src= preloads. --- demo/asset_card.js | 8 ++++++-- lib/player.js | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/demo/asset_card.js b/demo/asset_card.js index 89d57d9021..ff90e846f9 100644 --- a/demo/asset_card.js +++ b/demo/asset_card.js @@ -272,8 +272,12 @@ shakaDemo.AssetCard = class { try { await shakaDemoMain.preloadAsset(this.asset_); this.remakeButtons(); - await this.asset_.preloadManager.waitForFinish(); - this.asset_.preloaded = true; + if (this.asset_.preloadManager) { + await this.asset_.preloadManager.waitForFinish(); + this.asset_.preloaded = true; + } else { + this.asset_.preloadFailed = true; + } } catch (error) { this.asset_.preloadManager = null; this.asset_.preloadFailed = true; diff --git a/lib/player.js b/lib/player.js index 0d01a889c9..5ee0e44a8b 100644 --- a/lib/player.js +++ b/lib/player.js @@ -1627,8 +1627,9 @@ shaka.Player = class extends shaka.util.FakeEventTarget { shaka.util.Error.Severity.CRITICAL, shaka.util.Error.Category.PLAYER, shaka.util.Error.Code.SRC_EQUALS_PRELOAD_NOT_SUPPORTED)); + } else { + preloadManager.start().catch((error) => {}); // Catch errors. } - preloadManager.start().catch((error) => {}); // Catch errors. return preloadManager; }