Skip to content

Commit

Permalink
feat(analytics): track the type of audio track
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
amtins committed Oct 29, 2024
1 parent 606126f commit cda0d7a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/trackers/SRGAnalytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ class SRGAnalytics {

if (this.isAudioTrackEnabled()) {
labels.media_audio_track = this.getCurrentAudioTrack();
labels.media_audiodescription_on = this.isAudioDescriptionEnabled();
}

if (this.isTextTrackEnabled()) {
Expand Down Expand Up @@ -528,6 +529,19 @@ class SRGAnalytics {
}
}

/**
* Check if the audio description track is enabled.
*
* @returns {Boolean} __true__ if enabled __false__ otherwise.
*/
isAudioDescriptionEnabled() {
const currentTrack = Array
.from(this.player.audioTracks())
.find(track => track.enabled && track.kind.includes('desc'));

return Boolean(currentTrack);
}

/**
* Check if the audio track is enabled.
*
Expand Down

0 comments on commit cda0d7a

Please sign in to comment.