Skip to content

Commit

Permalink
feat: Add safeMargin as a parameter of the player selectAudioLanguage…
Browse files Browse the repository at this point in the history
… method (#5316)

Adding `safeMargin` as a parameter of the player `selectAudioLanguage`
method so it is possible to customize the buffer value when changing
tracks.
  • Loading branch information
davidezordan authored Jun 15, 2023
1 parent 6104b57 commit e4a4138
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Code It <*@code-it.fr>
Damien Deis <[email protected]>
Dany L'Hébreux <[email protected]>
Dave Nicholas <[email protected]>
Davide Zordan <[email protected]>
Dl Dador <[email protected]>
Edgeware AB <*@edgeware.tv>
Enson Choy <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Costel Madalin Grecu <[email protected]>
Damien Deis <[email protected]>
Dany L'Hébreux <[email protected]>
Dave Nicholas <[email protected]>
Davide Zordan <[email protected]>
Dl Dador <[email protected]>
Donato Borrello <[email protected]>
Duc Pham <[email protected]>
Expand Down
5 changes: 3 additions & 2 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -4173,9 +4173,10 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
* @param {string} language
* @param {string=} role
* @param {number=} channelsCount
* @param {number=} safeMargin
* @export
*/
selectAudioLanguage(language, role, channelsCount = 0) {
selectAudioLanguage(language, role, channelsCount = 0, safeMargin = 0) {
const LanguageUtils = shaka.util.LanguageUtils;

if (this.manifest_ && this.playhead_) {
Expand Down Expand Up @@ -4208,7 +4209,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
}
if (bestVariant) {
const track = shaka.util.StreamUtils.variantToTrack(bestVariant);
this.selectVariantTrack(track, /* clearBuffer= */ true);
this.selectVariantTrack(track, /* clearBuffer= */ true, safeMargin);
return;
}

Expand Down

0 comments on commit e4a4138

Please sign in to comment.