Skip to content

Commit 93dfd4f

Browse files
committed
Maintain startup event order using autoStartLoad for expected level and audioTrack getter results on MANIFEST_LOADING
Resolves #6891
1 parent 0af1391 commit 93dfd4f

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

api-extractor/report/hls.js.api.md

+2
Original file line numberDiff line numberDiff line change
@@ -3646,6 +3646,8 @@ export interface ManifestLoadedData {
36463646
// (undocumented)
36473647
contentSteering: ContentSteeringOptions | null;
36483648
// (undocumented)
3649+
isMediaPlaylist?: boolean;
3650+
// (undocumented)
36493651
levels: LevelParsed[];
36503652
// (undocumented)
36513653
networkDetails: any;

src/hls.ts

+6
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,12 @@ export default class Hls implements HlsEventEmitter {
300300
if (typeof onErrorOut === 'function') {
301301
this.on(Events.ERROR, onErrorOut, errorController);
302302
}
303+
// Autostart load handler
304+
this.on(
305+
Events.MANIFEST_LOADED,
306+
playListLoader.onManifestLoaded,
307+
playListLoader,
308+
);
303309
}
304310

305311
createController(ControllerClass, components) {

src/loader/playlist-loader.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type {
1919
ErrorData,
2020
LevelLoadingData,
2121
LevelsUpdatedData,
22+
ManifestLoadedData,
2223
ManifestLoadingData,
2324
TrackLoadingData,
2425
} from '../types/events';
@@ -495,8 +496,12 @@ class PlaylistLoader implements NetworkComponentAPI {
495496
startTimeOffset,
496497
variableList,
497498
});
499+
}
498500

499-
this.checkAutostartLoad();
501+
onManifestLoaded(event: Events.MANIFEST_LOADED, data: ManifestLoadedData) {
502+
if (!data.isMediaPlaylist) {
503+
this.checkAutostartLoad();
504+
}
500505
}
501506

502507
private handleTrackOrLevelPlaylist(
@@ -549,6 +554,7 @@ class PlaylistLoader implements NetworkComponentAPI {
549554
contentSteering: null,
550555
startTimeOffset: null,
551556
variableList: null,
557+
isMediaPlaylist: true,
552558
});
553559
}
554560

src/types/events.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import type {
77
SourceBufferName,
88
SourceBufferTrackSet,
99
} from './buffer';
10-
import type { ChunkMetadata } from './transmuxer';
11-
import type { ErrorDetails, ErrorTypes } from '../errors';
1210
import type { MetadataSample, UserdataSample } from './demuxer';
1311
import type {
1412
HdcpLevel,
@@ -27,13 +25,15 @@ import type {
2725
PlaylistLoaderContext,
2826
} from './loader';
2927
import type { MediaPlaylist, MediaPlaylistType } from './media-playlist';
28+
import type { ChunkMetadata } from './transmuxer';
3029
import type { SteeringManifest } from '../controller/content-steering-controller';
3130
import type { IErrorAction } from '../controller/error-controller';
3231
import type { HlsAssetPlayer } from '../controller/interstitial-player';
3332
import type {
3433
InterstitialScheduleDurations,
3534
InterstitialScheduleItem,
3635
} from '../controller/interstitials-schedule';
36+
import type { ErrorDetails, ErrorTypes } from '../errors';
3737
import type { HlsListeners } from '../events';
3838
import type { Fragment, MediaFragment, Part } from '../loader/fragment';
3939
import type {
@@ -138,6 +138,7 @@ export interface ManifestLoadedData {
138138
subtitles?: MediaPlaylist[];
139139
url: string;
140140
variableList: VariableMap | null;
141+
isMediaPlaylist?: boolean;
141142
}
142143

143144
export interface ManifestParsedData {

0 commit comments

Comments
 (0)