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

feat(FEC-11964): Allow configuring player to auto-select audio track according to browser locale #640

Merged
merged 10 commits into from
Feb 22, 2022

Conversation

yairans
Copy link
Contributor

@yairans yairans commented Feb 22, 2022

Description of the Changes

add the option to set playback.audioLanguage: 'auto' and compare with the locale then

Solves FEC-11964

CheckLists

  • changes have been done against master branch, and PR does not conflict
  • new unit / functional tests have been added (whenever applicable)
  • test are passing in local environment
  • Travis tests are passing (or test results are not worse than on master branch :))
  • Docs have been updated

@yairans yairans requested a review from a team February 22, 2022 10:27
@yairans yairans self-assigned this Feb 22, 2022
docs/configuration.md Outdated Show resolved Hide resolved
@@ -691,7 +691,7 @@ var config = {
>
> > ### config.playback.audioLanguage
> >
> > ##### Type: `string`
> > ##### Type: `string || "auto"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean the default is auto ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. string means language like 'en' etc. or 'auto'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I understand, "auto" is a value and not a type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right it's a value, specific value so it's documented explicitly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's already in the description, why does it need to be in the type as well ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no special reason, just to be aligned with the text language documentation - https://github.com/kaltura/playkit-js/blob/master/docs/configuration.md#type-string--auto

src/player.js Outdated
* @private
* @returns {string} - The track language to set by default.
*/
_getLanguage(configuredLanguage: string, defaultTrack: ?TextTrack): string {
_getLanguage(configuredLanguage: string, defaultTrack: ?(TextTrack | AudioTrack)): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that writing it like in _setDefaultTrack, with a typed function and passing the tracks from outside, is cleaner than having an if inside the function.

And if we don't use language outside _setDefaultTrack anyway, you can also merge _setDefaultTrack with _getLanguage, or call _getLanguage from inside _setDefaultTrack.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

src/player.js Outdated
@@ -2548,25 +2548,29 @@ export default class Player extends FakeEventTarget {
const activeTracks = this.getActiveTracks();
const playbackConfig = this.config.playback;
const offTextTrack: ?Track = this._getTextTracks().find(track => TextTrack.langComparer(OFF, track.language));
let currentOrConfiguredTextLang = this._playbackAttributesState.textLanguage || this._getLanguage(playbackConfig.textLanguage, activeTracks.text);
let currentOrConfiguredAudioLang = this._playbackAttributesState.audioLanguage || playbackConfig.audioLanguage;
let currentOrConfiguredTextLang =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

src/player.js Outdated
let currentOrConfiguredTextLang =
this._playbackAttributesState.textLanguage ||
this._getLanguage<TextTrack>(this._getTextTracks(), playbackConfig.textLanguage, activeTracks.text);
let currentOrConfiguredAudioLang =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

@yairans yairans merged commit ada882c into master Feb 22, 2022
@yairans yairans deleted the FEC-11964 branch February 22, 2022 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants