Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

bugfix: DEFAULT=YES on caption tracks was not being respected. #3781

Merged
merged 1 commit into from Apr 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/controller/subtitle-track-controller.ts
Expand Up @@ -191,13 +191,15 @@ class SubtitleTrackController extends BasePlaylistController {
const lastTrack = this.tracksInGroup
? this.tracksInGroup[this.trackId]
: undefined;
const initialTrackId =
this.findTrackId(lastTrack?.name) || this.findTrackId();

const subtitleTracks = this.tracks.filter(
(track): boolean => !textGroupId || track.groupId === textGroupId
);
this.groupId = textGroupId;
this.tracksInGroup = subtitleTracks;
const initialTrackId =
this.findTrackId(lastTrack?.name) || this.findTrackId();
this.groupId = textGroupId;

const subtitleTracksUpdated: SubtitleTracksUpdatedData = {
subtitleTracks,
};
Expand All @@ -213,9 +215,9 @@ class SubtitleTrackController extends BasePlaylistController {
}

private findTrackId(name?: string): number {
const audioTracks = this.tracksInGroup;
for (let i = 0; i < audioTracks.length; i++) {
const track = audioTracks[i];
const textTracks = this.tracksInGroup;
for (let i = 0; i < textTracks.length; i++) {
const track = textTracks[i];
if (!this.selectDefaultTrack || track.default) {
if (!name || name === track.name) {
return track.id;
Expand Down