Added optional flushImmediate argument to setAudioOption

This commit is contained in:
Kyle Seager
2026-04-10 02:05:38 -06:00
committed by Rob Walch
parent d6c08a7826
commit 84d322496d
4 changed files with 38 additions and 1 deletions
+1
View File
@@ -178,6 +178,7 @@ export type AudioSelectionOption = {
audioCodec?: string;
groupId?: string;
default?: boolean;
flushImmediate?: boolean;
};
// Warning: (ae-missing-release-tag) "AudioStreamController" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+4 -1
View File
@@ -282,7 +282,10 @@ class AudioTrackController extends BasePlaylistController {
);
if (groupIndex > -1) {
const track = this.tracksInGroup[groupIndex];
this.setAudioTrack(groupIndex);
this.setAudioTrack(
groupIndex,
'flushImmediate' in audioOption && audioOption.flushImmediate,
);
return track;
} else if (currentTrack) {
// Find option in nearest level audio group
+1
View File
@@ -32,6 +32,7 @@ export type AudioSelectionOption = {
audioCodec?: string;
groupId?: string;
default?: boolean;
flushImmediate?: boolean;
};
export type SubtitleSelectionOption = {
@@ -523,6 +523,38 @@ describe('AudioTrackController', function () {
});
});
describe('setAudioOption with flushImmediate', function () {
beforeEach(function () {
hls.levelController = {
levels: [
{
audioGroups: ['1'],
},
],
};
audioTrackController.tracks = tracks;
audioTrackController.onLevelLoading(Events.LEVEL_LOADING, {
level: 0,
});
});
it('should pass flushImmediate=true to AUDIO_TRACK_SWITCHING when specified in AudioSelectionOption', function () {
const triggerSpy = sinon.spy(hls, 'trigger');
(audioTrackController as any).setAudioOption({
name: 'B',
flushImmediate: true,
});
expect(triggerSpy).to.have.been.calledWith(
Events.AUDIO_TRACK_SWITCHING,
sinon.match({
id: 1,
flushImmediate: true,
}),
);
});
});
describe('audioTrack with flushImmediate', function () {
beforeEach(function () {
hls.levelController = {