fix: lock preload audio codec and disable PreloadManager ABR

This commit is contained in:
binimum 2026-04-04 21:01:32 +00:00 committed by GitHub
parent 54e337d8d7
commit 6651136e5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -555,6 +555,17 @@ export class Player {
if (stats && stats.estimatedBandwidth) {
preloadConfig.abr.defaultBandwidthEstimate = stats.estimatedBandwidth;
}
// Lock the preload to the exact current audio codec to prevent ABR mismatch,
// which forces the player to discard and re-fetch chunks on slow connections.
preloadConfig.abr.enabled = false;
try {
const variants = typeof this.shakaPlayer.getVariantTracks === 'function' ? this.shakaPlayer.getVariantTracks() : [];
const activeVariant = variants.find(v => v.active);
if (activeVariant && activeVariant.audioCodec) {
preloadConfig.preferredAudioCodecs = [activeVariant.audioCodec];
}
} catch (e) {}
}
const preloadManager = await this.shakaPlayer.preload(streamUrl, null, null, preloadConfig);
streamInfo.preloadManager = preloadManager;