hls.js 1.6.0-beta.2.0.canary.10892 → 1.6.0-beta.2.0.canary.10895
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hls.js +55 -49
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +2 -2
- package/dist/hls.light.min.js +1 -1
- package/dist/hls.light.mjs +2 -2
- package/dist/hls.min.js +1 -1
- package/dist/hls.min.js.map +1 -1
- package/dist/hls.mjs +55 -52
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/package.json +2 -2
- package/src/controller/audio-stream-controller.ts +27 -31
@@ -13,8 +13,11 @@ import {
|
|
13
13
|
alignDiscontinuities,
|
14
14
|
alignMediaPlaylistByPDT,
|
15
15
|
} from '../utils/discontinuities';
|
16
|
-
import {
|
17
|
-
|
16
|
+
import {
|
17
|
+
audioMatchPredicate,
|
18
|
+
matchesOption,
|
19
|
+
useAlternateAudio,
|
20
|
+
} from '../utils/rendition-helper';
|
18
21
|
import type { FragmentTracker } from './fragment-tracker';
|
19
22
|
import type Hls from '../hls';
|
20
23
|
import type { Fragment, MediaFragment, Part } from '../loader/fragment';
|
@@ -358,9 +361,8 @@ class AudioStreamController
|
|
358
361
|
if (bufferInfo === null) {
|
359
362
|
return;
|
360
363
|
}
|
361
|
-
const { bufferedTrack, switchingTrack } = this;
|
362
364
|
|
363
|
-
if (!switchingTrack && this._streamEnded(bufferInfo, trackDetails)) {
|
365
|
+
if (!this.switchingTrack && this._streamEnded(bufferInfo, trackDetails)) {
|
364
366
|
hls.trigger(Events.BUFFER_EOS, { type: 'audio' });
|
365
367
|
this.state = State.ENDED;
|
366
368
|
return;
|
@@ -372,17 +374,10 @@ class AudioStreamController
|
|
372
374
|
const fragments = trackDetails.fragments;
|
373
375
|
const start = fragments[0].start;
|
374
376
|
const loadPosition = this.getLoadPosition();
|
375
|
-
|
377
|
+
const targetBufferTime = this.flushing ? loadPosition : bufferInfo.end;
|
376
378
|
|
377
|
-
if (switchingTrack && media) {
|
379
|
+
if (this.switchingTrack && media) {
|
378
380
|
const pos = loadPosition;
|
379
|
-
// STABLE
|
380
|
-
if (
|
381
|
-
bufferedTrack &&
|
382
|
-
!mediaAttributesIdentical(switchingTrack.attrs, bufferedTrack.attrs)
|
383
|
-
) {
|
384
|
-
targetBufferTime = pos;
|
385
|
-
}
|
386
381
|
// if currentTime (pos) is less than alt audio playlist start time, it means that alt audio is ahead of currentTime
|
387
382
|
if (trackDetails.PTSKnown && pos < start) {
|
388
383
|
// if everything is buffered from pos to start or if audio buffer upfront, let's seek to start
|
@@ -398,7 +393,7 @@ class AudioStreamController
|
|
398
393
|
// if buffer length is less than maxBufLen, or near the end, find a fragment to load
|
399
394
|
if (
|
400
395
|
bufferLen >= maxBufLen &&
|
401
|
-
!switchingTrack &&
|
396
|
+
!this.switchingTrack &&
|
402
397
|
targetBufferTime < fragments[fragments.length - 1].start
|
403
398
|
) {
|
404
399
|
return;
|
@@ -1020,23 +1015,24 @@ class AudioStreamController
|
|
1020
1015
|
}
|
1021
1016
|
|
1022
1017
|
private flushAudioIfNeeded(switchingTrack: MediaPlaylist) {
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1018
|
+
if (this.media && this.bufferedTrack) {
|
1019
|
+
const { name, lang, assocLang, characteristics, audioCodec, channels } =
|
1020
|
+
this.bufferedTrack;
|
1021
|
+
if (
|
1022
|
+
!matchesOption(
|
1023
|
+
{ name, lang, assocLang, characteristics, audioCodec, channels },
|
1024
|
+
switchingTrack,
|
1025
|
+
audioMatchPredicate,
|
1026
|
+
)
|
1027
|
+
) {
|
1028
|
+
if (useAlternateAudio(switchingTrack.url, this.hls)) {
|
1029
|
+
this.log('Switching audio track : flushing all audio');
|
1030
|
+
super.flushMainBuffer(0, Number.POSITIVE_INFINITY, 'audio');
|
1031
|
+
this.bufferedTrack = null;
|
1032
|
+
} else {
|
1033
|
+
// Main is being buffered. Set bufferedTrack so that it is flushed when switching back to alt-audio
|
1034
|
+
this.bufferedTrack = switchingTrack;
|
1035
|
+
}
|
1040
1036
|
}
|
1041
1037
|
}
|
1042
1038
|
}
|