From 54e337d8d708676ca9b9b82286f9eaa1f3039311 Mon Sep 17 00:00:00 2001 From: binimum Date: Sat, 4 Apr 2026 20:56:09 +0000 Subject: [PATCH] fix: pass current abr estimatedBandwidth to preloadManager --- js/player.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/js/player.js b/js/player.js index 75c0655..a3e56f1 100644 --- a/js/player.js +++ b/js/player.js @@ -548,7 +548,15 @@ export class Player { if (streamUrl.includes('.mpd') || streamUrl.includes('.m3u8')) { if (this.shakaInitialized && this.shakaPlayer && typeof this.shakaPlayer.preload === 'function') { try { - const preloadManager = await this.shakaPlayer.preload(streamUrl); + let preloadConfig = undefined; + if (typeof this.shakaPlayer.getConfiguration === 'function') { + preloadConfig = this.shakaPlayer.getConfiguration(); + const stats = typeof this.shakaPlayer.getStats === 'function' ? this.shakaPlayer.getStats() : null; + if (stats && stats.estimatedBandwidth) { + preloadConfig.abr.defaultBandwidthEstimate = stats.estimatedBandwidth; + } + } + const preloadManager = await this.shakaPlayer.preload(streamUrl, null, null, preloadConfig); streamInfo.preloadManager = preloadManager; } catch (e) { // Ignore preload errors, will just load fresh