diff --git a/js/player.js b/js/player.js index a3e56f1..f39bc67 100644 --- a/js/player.js +++ b/js/player.js @@ -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;