Skip to content

Commit

Permalink
feat: return tracks labels
Browse files Browse the repository at this point in the history
  • Loading branch information
tymmesyde committed Jan 16, 2025
1 parent 54b3930 commit 0046fef
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/HTMLVideo/HTMLVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ function HTMLVideo(options) {
.map(function(track, index) {
return Object.freeze({
id: 'EMBEDDED_' + String(index),
lang: track.language,
label: track.label,
lang: track.language.length > 0 ? track.language : null,
label: track.label.length > 0 ? track.label : null,
origin: 'EMBEDDED',
embedded: true
});
Expand Down
4 changes: 2 additions & 2 deletions src/TitanVideo/TitanVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ function TitanVideo(options) {
return Object.freeze({
id: 'EMBEDDED_' + String(index),
lang: track.language,
label: track.label || track.language,
label: track.label.length > 0 ? track.label : null,
origin: 'EMBEDDED',
embedded: true
});
Expand Down Expand Up @@ -265,7 +265,7 @@ function TitanVideo(options) {
return Object.freeze({
id: 'EMBEDDED_' + String(index),
lang: track.language,
label: track.label || track.language,
label: track.label.length > 0 ? track.label : null,
origin: 'EMBEDDED',
embedded: true
});
Expand Down
22 changes: 20 additions & 2 deletions src/TizenVideo/TizenVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,19 @@ function TizenVideo(options) {
textTrackLang = extendedTrackData.lang || 'eng';
}
}
var textTrackLabel = null;
if (((tracksData || {}).subs || []).length) {
var extendedTrackData = tracksData.subs.find(function(el) {
return (el || {}).id-1 === textTrack.index;
});
if (extendedTrackData) {
textTrackLabel = extendedTrackData.label;
}
}
textTracks.push({
id: textTrackId,
lang: textTrackLang,
label: textTrackLang,
label: textTrackLabel,
origin: 'EMBEDDED',
embedded: true,
mode: !disabledSubs && textTrackId === currentSubTrack ? 'showing' : 'disabled',
Expand Down Expand Up @@ -354,10 +363,19 @@ function TizenVideo(options) {
audioTrackLang = extendedTrackData.lang || 'eng';
}
}
var audioTrackLabel = null;
if (((tracksData || {}).subs || []).length) {
var extendedTrackData = tracksData.subs.find(function(el) {
return (el || {}).id-1 === audioTrack.index;
});
if (extendedTrackData) {
audioTrackLabel = extendedTrackData.label;
}
}
audioTracks.push({
id: audioTrackId,
lang: audioTrackLang,
label: audioTrackLang,
label: audioTrackLabel,
origin: 'EMBEDDED',
embedded: true,
mode: audioTrackId === currentAudioTrack ? 'showing' : 'disabled',
Expand Down
4 changes: 2 additions & 2 deletions src/WebOsVideo/WebOsVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ function WebOsVideo(options) {
textTracks.push({
id: 'EMBEDDED_' + textTrackId,
lang: track.lang || 'eng',
label: track.lang || 'eng',
label: track.label.length > 0 ? track.label : null,
origin: 'EMBEDDED',
embedded: true,
mode: textTrackId === currentSubTrack ? 'showing' : 'disabled',
Expand All @@ -392,7 +392,7 @@ function WebOsVideo(options) {
audioTracks.push({
id: 'EMBEDDED_' + audioTrackId,
lang: track.lang || 'eng',
label: track.lang || 'eng',
label: track.label.length > 0 ? track.label : null,
origin: 'EMBEDDED',
embedded: true,
mode: audioTrackId === currentAudioTrack ? 'showing' : 'disabled',
Expand Down

0 comments on commit 0046fef

Please sign in to comment.