Skip to content

Commit

Permalink
Merge pull request #96 from Stremio/feat/tracks-labels
Browse files Browse the repository at this point in the history
feat: return tracks labels
  • Loading branch information
jaruba authored Jan 16, 2025
2 parents 54b3930 + aba3de2 commit 41cf05b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/HTMLVideo/HTMLVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function HTMLVideo(options) {
return Object.freeze({
id: 'EMBEDDED_' + String(index),
lang: track.language,
label: track.label,
label: 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 || 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 || null,
origin: 'EMBEDDED',
embedded: true
});
Expand Down
8 changes: 6 additions & 2 deletions src/TizenVideo/TizenVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,20 @@ function TizenVideo(options) {
extra = JSON.parse(textTrack.extra_info);
} catch(e) {}
var textTrackLang = typeof extra.track_lang === 'string' && extra.track_lang.length > 0 ? extra.track_lang.trim() : null;
var textTrackLabel = null;
if (((tracksData || {}).subs || []).length) {
var extendedTrackData = tracksData.subs.find(function(el) {
return (el || {}).id-1 === textTrack.index;
});
if (extendedTrackData) {
textTrackLang = extendedTrackData.lang || 'eng';
textTrackLabel = extendedTrackData.label || null;
}
}
textTracks.push({
id: textTrackId,
lang: textTrackLang,
label: textTrackLang,
label: textTrackLabel,
origin: 'EMBEDDED',
embedded: true,
mode: !disabledSubs && textTrackId === currentSubTrack ? 'showing' : 'disabled',
Expand Down Expand Up @@ -346,18 +348,20 @@ function TizenVideo(options) {
extra = JSON.parse(audioTrack.extra_info);
} catch(e) {}
var audioTrackLang = typeof extra.language === 'string' && extra.language.length > 0 ? extra.language : null;
var audioTrackLabel = null;
if (((tracksData || {}).audio || []).length) {
var extendedTrackData = tracksData.audio.find(function(el) {
return (el || {}).id-1 === audioTrack.index;
});
if (extendedTrackData) {
audioTrackLang = extendedTrackData.lang || 'eng';
audioTrackLabel = extendedTrackData.label || null;
}
}
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 || 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 || null,
origin: 'EMBEDDED',
embedded: true,
mode: audioTrackId === currentAudioTrack ? 'showing' : 'disabled',
Expand Down

0 comments on commit 41cf05b

Please sign in to comment.