fix: pass current abr estimatedBandwidth to preloadManager

This commit is contained in:
binimum 2026-04-04 20:56:09 +00:00 committed by GitHub
parent d7cbaa454d
commit 54e337d8d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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