Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Maintain startup event order with autoStartLoad #6893

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading