fix: lock preload audio codec and disable PreloadManager ABR
This commit is contained in:
parent
54e337d8d7
commit
6651136e5b
1 changed files with 11 additions and 0 deletions
11
js/player.js
11
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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue