Skip to content

Commit cda0d7a

Browse files
committed
feat(analytics): track the type of audio track
Resolves #265 by allowing the ADI team to measure videos played with the described audio track enabled. - add a function to indicate whether the activated audio track is audio described or not - add an event label named `media_audiodescription_on`
1 parent 606126f commit cda0d7a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/trackers/SRGAnalytics.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ class SRGAnalytics {
374374

375375
if (this.isAudioTrackEnabled()) {
376376
labels.media_audio_track = this.getCurrentAudioTrack();
377+
labels.media_audiodescription_on = this.isAudioDescriptionEnabled();
377378
}
378379

379380
if (this.isTextTrackEnabled()) {
@@ -528,6 +529,19 @@ class SRGAnalytics {
528529
}
529530
}
530531

532+
/**
533+
* Check if the audio description track is enabled.
534+
*
535+
* @returns {Boolean} __true__ if enabled __false__ otherwise.
536+
*/
537+
isAudioDescriptionEnabled() {
538+
const currentTrack = Array
539+
.from(this.player.audioTracks())
540+
.find(track => track.enabled && track.kind.includes('desc'));
541+
542+
return Boolean(currentTrack);
543+
}
544+
531545
/**
532546
* Check if the audio track is enabled.
533547
*

0 commit comments

Comments
 (0)