Skip to content

Commit

Permalink
Merge pull request #3781 from video-dev/bugfix/3780
Browse files Browse the repository at this point in the history
bugfix: DEFAULT=YES on caption tracks was not being respected.
  • Loading branch information
robwalch committed Apr 16, 2021
2 parents eee944c + 3cc1555 commit 2274d91
Showing 1 changed file with 8 additions and 6 deletions.
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

0 comments on commit 2274d91

Please sign in to comment.