From 0046fefaab0e3d603ce1ab792635e2ae29d778f9 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 16 Jan 2025 10:00:13 +0100 Subject: [PATCH] feat: return tracks labels --- src/HTMLVideo/HTMLVideo.js | 4 ++-- src/TitanVideo/TitanVideo.js | 4 ++-- src/TizenVideo/TizenVideo.js | 22 ++++++++++++++++++++-- src/WebOsVideo/WebOsVideo.js | 4 ++-- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/HTMLVideo/HTMLVideo.js b/src/HTMLVideo/HTMLVideo.js index 2ee6a79..91cab91 100644 --- a/src/HTMLVideo/HTMLVideo.js +++ b/src/HTMLVideo/HTMLVideo.js @@ -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 }); diff --git a/src/TitanVideo/TitanVideo.js b/src/TitanVideo/TitanVideo.js index 7a5c178..ca92fa2 100644 --- a/src/TitanVideo/TitanVideo.js +++ b/src/TitanVideo/TitanVideo.js @@ -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 }); @@ -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 }); diff --git a/src/TizenVideo/TizenVideo.js b/src/TizenVideo/TizenVideo.js index 21b0b78..0cc3166 100644 --- a/src/TizenVideo/TizenVideo.js +++ b/src/TizenVideo/TizenVideo.js @@ -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', @@ -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', diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 02ace2c..080b339 100644 --- a/src/WebOsVideo/WebOsVideo.js +++ b/src/WebOsVideo/WebOsVideo.js @@ -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', @@ -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',