Skip to content

Commit

Permalink
feat: Adds ChannelCount as a filter to the Player Select Audio Track …
Browse files Browse the repository at this point in the history
…Method (#4552)

Adds channelCount to the Select Audio Track method, this allows for
selecting a audio track based on the channel count when the language,
codec and role are the same.

Closes #4550
  • Loading branch information
jlnabais committed Oct 7, 2022
1 parent 59ef54a commit 9dd945c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ V-Nova Limited <*@v-nova.com>
Wayne Morgan <wayne.morgan.dev@gmail.com>
Raymond Cheng <raycheng100@gmail.com>
Blue Billywig <*@bluebillywig.com>
João Nabais <jlnabais@gmail.com>
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,4 @@ Wayne Morgan <wayne.morgan.dev@gmail.com>
Yohann Connell <robinconnell@google.com>
Raymond Cheng <raycheng100@gmail.com>
Janroel Koppen <j.koppen@bluebillywig.com>
João Nabais <jlnabais@gmail.com>
9 changes: 5 additions & 4 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -4042,20 +4042,21 @@ shaka.Player = class extends shaka.util.FakeEventTarget {

/**
* Sets the current audio language and current variant role to the selected
* language and role, and chooses a new variant if need be. If the player has
* not loaded any content, this will be a no-op.
* language, role and channel count, and chooses a new variant if need be.
* If the player has not loaded any content, this will be a no-op.
*
* @param {string} language
* @param {string=} role
* @param {number=} channelsCount
* @export
*/
selectAudioLanguage(language, role) {
selectAudioLanguage(language, role, channelsCount = 0) {
const LanguageUtils = shaka.util.LanguageUtils;

if (this.manifest_ && this.playhead_) {
this.currentAdaptationSetCriteria_ =
new shaka.media.PreferenceBasedCriteria(language, role || '',
/* channelCount= */ 0, /* label= */ '');
channelsCount, /* label= */ '');

const diff = (a, b) => {
if (!a.video && !b.video) {
Expand Down

0 comments on commit 9dd945c

Please sign in to comment.