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-14087): define audio-description audio tracks #797

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var config = {
autoplay: false,
loop: false,
allowMutedAutoPlay: true,
updateAudioDescriptionFlavors: true,
muted: false,
pictureInPicture: true,
options: {
Expand Down Expand Up @@ -792,6 +793,7 @@ var config = {
> loop: boolean,
> autopause: boolean,
> allowMutedAutoPlay: boolean,
> updateAudioDescriptionFlavors: boolean,
> muted: boolean,
> pictureInPicture: boolean,
> options: PKPlaybackOptionsObject,
Expand All @@ -818,6 +820,7 @@ var config = {
> autoplay: false,
> loop: false,
> allowMutedAutoPlay: true,
> updateAudioDescriptionFlavors: true,
> muted: false,
> pictureInPicture: true,
> playAdsWithMSE: false,
Expand Down Expand Up @@ -1078,6 +1081,16 @@ var config = {
>
> ##
>
> > ### config.playback.updateAudioDescriptionFlavors
> >
> > ##### Type: `boolean`
> >
> > ##### Default: `true`
> >
> > ##### Description: Updates audio flavors that has "audio_description" tag
semarche-kaltura marked this conversation as resolved.
Show resolved Hide resolved
>
> ##
>
> > ### config.playback.autopause
> >
> > ##### Type: `boolean`
Expand Down
1 change: 1 addition & 0 deletions flow-typed/types/playback-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ declare type PKPlaybackConfigObject = {
preload: string,
autoplay: PKAutoPlayTypes,
allowMutedAutoPlay: boolean,
updateAudioDescriptionFlavors: boolean,
muted: boolean,
pictureInPicture: boolean,
streamPriority: Array<PKStreamPriorityObject>,
Expand Down
1 change: 1 addition & 0 deletions src/player-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const DefaultConfig = {
loop: false,
autopause: false,
allowMutedAutoPlay: true,
updateAudioDescriptionFlavors: true,
muted: false,
pictureInPicture: true,
options: {
Expand Down
20 changes: 20 additions & 0 deletions src/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2470,6 +2470,26 @@ export default class Player extends FakeEventTarget {
*/
public _updateTracks(tracks: Array<Track>): void {
Player._logger.debug('Tracks changed', tracks);

if (this.config.playback.updateAudioDescriptionFlavors && this._sources.metadata?.audioFlavors) {
semarche-kaltura marked this conversation as resolved.
Show resolved Hide resolved
let audioTracksIndex = 0;
// iterate over the audio tracks and set the isAudioDescription flag based on the audioFlavors metadata
tracks.forEach((track) => {
semarche-kaltura marked this conversation as resolved.
Show resolved Hide resolved
if (track instanceof AudioTrack) {
track.isAudioDescription = Boolean(this._sources.metadata.audioFlavors?.[audioTracksIndex]?.isAudioDescription);
if (track.isAudioDescription) {
// set the language to ad-<language> for audio description tracks
track.language = `ad-${track.language}`;
SivanA-Kaltura marked this conversation as resolved.
Show resolved Hide resolved
if (!this._sources.metadata?.audioFlavors?.[audioTracksIndex]?.label) {
// add "Audio Description" to the label if custom label is not provided
track.label = `${track.label} - Audio Description`;
SivanA-Kaltura marked this conversation as resolved.
Show resolved Hide resolved
}
}
audioTracksIndex++;
}
});
}

this._tracks = tracks?.concat(this._externalCaptionsHandler.getExternalTracks(tracks));
this._applyABRRestriction(this._config);
this._addTextTrackOffOption();
Expand Down
9 changes: 7 additions & 2 deletions src/track/audio-track.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
//@flow
import Track from './track';

/**
* Audio track representation of the player.
* @classdesc
*/
class AudioTrack extends Track {}
class AudioTrack extends Track {
semarche-kaltura marked this conversation as resolved.
Show resolved Hide resolved
/**

Check failure on line 8 in src/track/audio-track.ts

View workflow job for this annotation

GitHub Actions / lint / running-tests (ubuntu-latest)

Expected indentation of 2 spaces but found 4
* @member - is audio asset has audio description tag
* @type {boolean|undefined}
*/
public isAudioDescription?: boolean;

Check failure on line 12 in src/track/audio-track.ts

View workflow job for this annotation

GitHub Actions / lint / running-tests (ubuntu-latest)

Expected indentation of 2 spaces but found 4
}

export default AudioTrack;
9 changes: 9 additions & 0 deletions src/track/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ export default class Track {
this._available = isAvailable;
}

/**
* Setter for the language of the track.
* @public
* @param {string} value - The language of the track.
*/
public set language(value: string) {
this._language = value;
SivanA-Kaltura marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* @constructor
* @param {Object} settings - The track settings object.
Expand Down
1 change: 1 addition & 0 deletions src/types/metadata-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export type PKMetadataConfigObject = {
tags?: Object,
epgId?: string,
recordingId?: string
audioFlavors?: Array<any>,
};
1 change: 1 addition & 0 deletions src/types/playback-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type PKPlaybackConfigObject = {
preload: string,
autoplay: PKAutoPlayTypes,
allowMutedAutoPlay: boolean,
updateAudioDescriptionFlavors: boolean,
muted: boolean,
pictureInPicture: boolean,
streamPriority: Array<PKStreamPriorityObject>,
Expand Down
Loading