From 0046fefaab0e3d603ce1ab792635e2ae29d778f9 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 16 Jan 2025 10:00:13 +0100 Subject: [PATCH 1/3] 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', From f4ebfc96e7b261b15dd8628a89e5097f1fed5a62 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 16 Jan 2025 10:23:12 +0100 Subject: [PATCH 2/3] fix: tracks lang and label conditions --- src/HTMLVideo/HTMLVideo.js | 4 ++-- src/TitanVideo/TitanVideo.js | 4 ++-- src/WebOsVideo/WebOsVideo.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/HTMLVideo/HTMLVideo.js b/src/HTMLVideo/HTMLVideo.js index 91cab91..2599d67 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.length > 0 ? track.language : null, - label: track.label.length > 0 ? track.label : null, + lang: track.language, + label: track.label || null, origin: 'EMBEDDED', embedded: true }); diff --git a/src/TitanVideo/TitanVideo.js b/src/TitanVideo/TitanVideo.js index ca92fa2..ace082c 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.length > 0 ? track.label : null, + label: 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.length > 0 ? track.label : null, + label: track.label || null, origin: 'EMBEDDED', embedded: true }); diff --git a/src/WebOsVideo/WebOsVideo.js b/src/WebOsVideo/WebOsVideo.js index 080b339..5cba082 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.label.length > 0 ? track.label : null, + label: 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.label.length > 0 ? track.label : null, + label: track.label || null, origin: 'EMBEDDED', embedded: true, mode: audioTrackId === currentAudioTrack ? 'showing' : 'disabled', From aba3de2982432e6691b313f773d1255030d1f434 Mon Sep 17 00:00:00 2001 From: Alexandru Branza Date: Thu, 16 Jan 2025 14:05:13 +0200 Subject: [PATCH 3/3] Fix Tizen Player Duplication --- src/TizenVideo/TizenVideo.js | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/TizenVideo/TizenVideo.js b/src/TizenVideo/TizenVideo.js index 0cc3166..51d54e8 100644 --- a/src/TizenVideo/TizenVideo.js +++ b/src/TizenVideo/TizenVideo.js @@ -244,21 +244,14 @@ 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; - if (((tracksData || {}).subs || []).length) { - var extendedTrackData = tracksData.subs.find(function(el) { - return (el || {}).id-1 === textTrack.index; - }); - if (extendedTrackData) { - 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; + textTrackLang = extendedTrackData.lang || 'eng'; + textTrackLabel = extendedTrackData.label || null; } } textTracks.push({ @@ -355,21 +348,14 @@ 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'; - } - } - 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; + audioTrackLabel = extendedTrackData.label || null; } } audioTracks.push({