Skip to content

Commit

Permalink
Merge pull request #19 from Stremio/html-video-subs
Browse files Browse the repository at this point in the history
add prefix to embedded track ids
  • Loading branch information
nklhtv authored Apr 15, 2022
2 parents 9589ef8 + f0e2141 commit b6c820c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/HTMLVideo/HTMLVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function HTMLVideo(options) {
return Array.from(videoElement.textTracks)
.map(function(track, index) {
return Object.freeze({
id: String(index),
id: 'EMBEDDED_' + String(index),
lang: track.language,
label: track.label,
origin: 'EMBEDDED',
Expand All @@ -189,7 +189,7 @@ function HTMLVideo(options) {
return Array.from(videoElement.textTracks)
.reduce(function(result, track, index) {
if (result === null && track.mode === 'showing') {
return String(index);
return 'EMBEDDED_' + String(index);
}

return result;
Expand Down Expand Up @@ -238,7 +238,7 @@ function HTMLVideo(options) {
return hls.audioTracks
.map(function(track) {
return Object.freeze({
id: String(track.id),
id: 'EMBEDDED_' + String(track.id),
lang: typeof track.lang === 'string' && track.lang.length > 0 ?
track.lang
:
Expand All @@ -263,7 +263,7 @@ function HTMLVideo(options) {
return null;
}

return String(hls.audioTrack);
return 'EMBEDDED_' + String(hls.audioTrack);
}
case 'volume': {
if (destroyed || videoElement.volume === null || !isFinite(videoElement.volume)) {
Expand Down Expand Up @@ -371,7 +371,7 @@ function HTMLVideo(options) {
if (stream !== null) {
Array.from(videoElement.textTracks)
.forEach(function(track, index) {
track.mode = String(index) === propValue ? 'showing' : 'disabled';
track.mode = 'EMBEDDED_' + String(index) === propValue ? 'showing' : 'disabled';
});
var selecterdSubtitlesTrack = getProp('subtitlesTracks')
.find(function(track) {
Expand Down Expand Up @@ -449,7 +449,7 @@ function HTMLVideo(options) {
.find(function(track) {
return track.id === propValue;
});
hls.audioTrack = selecterdAudioTrack ? parseInt(selecterdAudioTrack.id, 10) : -1;
hls.audioTrack = selecterdAudioTrack ? parseInt(selecterdAudioTrack.id.split('_').pop(), 10) : -1;
if (selecterdAudioTrack) {
events.emit('audioTrackLoaded', selecterdAudioTrack);
}
Expand Down
2 changes: 1 addition & 1 deletion src/YouTubeVideo/YouTubeVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function YouTubeVideo(options) {
})
.map(function(track, index) {
return Object.freeze({
id: String(index),
id: 'EMBEDDED_' + String(index),
lang: track.languageCode,
label: typeof track.displayName === 'string' ? track.displayName : track.languageCode,
origin: 'EMBEDDED',
Expand Down

0 comments on commit b6c820c

Please sign in to comment.