Skip to content

Commit

Permalink
Maintain startup event order using autoStartLoad for expected level a…
Browse files Browse the repository at this point in the history
…nd audioTrack getter results on MANIFEST_LOADING

Resolves #6891
  • Loading branch information
robwalch committed Dec 6, 2024
1 parent 0af1391 commit 93dfd4f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions api-extractor/report/hls.js.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3646,6 +3646,8 @@ export interface ManifestLoadedData {
// (undocumented)
contentSteering: ContentSteeringOptions | null;
// (undocumented)
isMediaPlaylist?: boolean;
// (undocumented)
levels: LevelParsed[];
// (undocumented)
networkDetails: any;
Expand Down
6 changes: 6 additions & 0 deletions src/hls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ export default class Hls implements HlsEventEmitter {
if (typeof onErrorOut === 'function') {
this.on(Events.ERROR, onErrorOut, errorController);
}
// Autostart load handler
this.on(
Events.MANIFEST_LOADED,
playListLoader.onManifestLoaded,
playListLoader,
);
}

createController(ControllerClass, components) {
Expand Down
8 changes: 7 additions & 1 deletion src/loader/playlist-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type {
ErrorData,
LevelLoadingData,
LevelsUpdatedData,
ManifestLoadedData,
ManifestLoadingData,
TrackLoadingData,
} from '../types/events';
Expand Down Expand Up @@ -495,8 +496,12 @@ class PlaylistLoader implements NetworkComponentAPI {
startTimeOffset,
variableList,
});
}

this.checkAutostartLoad();
onManifestLoaded(event: Events.MANIFEST_LOADED, data: ManifestLoadedData) {
if (!data.isMediaPlaylist) {
this.checkAutostartLoad();
}
}

private handleTrackOrLevelPlaylist(
Expand Down Expand Up @@ -549,6 +554,7 @@ class PlaylistLoader implements NetworkComponentAPI {
contentSteering: null,
startTimeOffset: null,
variableList: null,
isMediaPlaylist: true,
});
}

Expand Down
5 changes: 3 additions & 2 deletions src/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import type {
SourceBufferName,
SourceBufferTrackSet,
} from './buffer';
import type { ChunkMetadata } from './transmuxer';
import type { ErrorDetails, ErrorTypes } from '../errors';
import type { MetadataSample, UserdataSample } from './demuxer';
import type {
HdcpLevel,
Expand All @@ -27,13 +25,15 @@ import type {
PlaylistLoaderContext,
} from './loader';
import type { MediaPlaylist, MediaPlaylistType } from './media-playlist';
import type { ChunkMetadata } from './transmuxer';
import type { SteeringManifest } from '../controller/content-steering-controller';
import type { IErrorAction } from '../controller/error-controller';
import type { HlsAssetPlayer } from '../controller/interstitial-player';
import type {
InterstitialScheduleDurations,
InterstitialScheduleItem,
} from '../controller/interstitials-schedule';
import type { ErrorDetails, ErrorTypes } from '../errors';
import type { HlsListeners } from '../events';
import type { Fragment, MediaFragment, Part } from '../loader/fragment';
import type {
Expand Down Expand Up @@ -138,6 +138,7 @@ export interface ManifestLoadedData {
subtitles?: MediaPlaylist[];
url: string;
variableList: VariableMap | null;
isMediaPlaylist?: boolean;
}

export interface ManifestParsedData {
Expand Down

0 comments on commit 93dfd4f

Please sign in to comment.