mirror of
https://github.com/video-dev/hls.js.git
synced 2026-05-17 13:30:38 +00:00
Added optional flushImmediate argument to setAudioOption
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user