Skip to content

Commit

Permalink
fix: turn off other tracks with native audio track
Browse files Browse the repository at this point in the history
Audio Tracks are supposed to allow multiple tracks at the same time.
Safari 15 has added, at least partial support for this.

In #7163, we stopped turning other tracks of manually since we already
were doing so in the AudioTrackList. However, this only worked for
non-native AudioTracks. Before Safari 15, Safari automatically turned
off the other tracks for us so things continued to work.

With this change, when native audio tracks are used, we will turn off
the other tracks, partially reverting #7163.

We currently do not have any tests or are set up for writing tests for
these proxy tracks. Adding such tests will take too long for not a lot
of benefit, unfortunately.

Fixes #7494.
  • Loading branch information
gkatsev committed Nov 12, 2021
1 parent 6c67c30 commit 7739c80
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/js/control-bar/audio-track-controls/audio-track-menu-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ class AudioTrackMenuItem extends MenuItem {
// the audio track list will automatically toggle other tracks
// off for us.
this.track.enabled = true;

// when native audio tracks are used, we want to make sure that other tracks are turned off
if (this.player_.tech_.featuresNativeAudioTracks) {
const tracks = this.player_.audioTracks();

for (let i = 0; i < tracks.length; i++) {
const track = tracks[i];

// skip the current track since we enabled it above
if (track === this.track) {
continue;
}

track.enabled = track === this.track;
}
}
}

/**
Expand Down

0 comments on commit 7739c80

Please sign in to comment.