Skip to content

Commit

Permalink
Always Use External MKV / MP4 Parsers for LG TV
Browse files Browse the repository at this point in the history
  • Loading branch information
jaruba committed Jun 6, 2024
1 parent eb57575 commit 88b77e2
Showing 1 changed file with 3 additions and 142 deletions.
145 changes: 3 additions & 142 deletions src/WebOsVideo/WebOsVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,10 @@ function WebOsVideo(options) {

var isLoaded = null;

var knownMediaId = false;

var subSize = 75;

var disabledSubs = true;

var subscribed = false;

var currentSubTrack = false;

var currentAudioTrack = false;
Expand All @@ -174,140 +170,6 @@ function WebOsVideo(options) {
char_opacity: 255
};

var setSubs = function (info) {
textTracks = [];
if (info.numSubtitleTracks) {
for (var i = 0; i < info.subtitleTrackInfo.length; i++) {
var textTrack = info.subtitleTrackInfo[i];
textTrack.index = i;
var textTrackLang = textTrack.language === '(null)' ? null : textTrack.language;

var textTrackId = 'EMBEDDED_' + textTrack.index;

if (!currentSubTrack && !textTracks.length) {
currentSubTrack = textTrackId;
}

textTracks.push({
id: textTrackId,
lang: textTrackLang,
label: textTrackLang,
origin: 'EMBEDDED',
embedded: true,
mode: textTrackId === currentSubTrack ? 'showing' : 'disabled',
});

}
onPropChanged('subtitlesTracks');
onPropChanged('selectedSubtitlesTrackId');
}
};

var setTracks = function (info) {
audioTracks = [];
if (info.numAudioTracks) {
for (var i = 0; i < info.audioTrackInfo.length; i++) {
var audioTrack = info.audioTrackInfo[i];
audioTrack.index = i;
var audioTrackId = 'EMBEDDED_' + audioTrack.index;
if (!currentAudioTrack && !audioTracks.length) {
currentAudioTrack = audioTrackId;
}
var audioTrackLang = audioTrack.language === '(null)' ? null : audioTrack.language;
audioTracks.push({
id: audioTrackId,
lang: audioTrackLang,
label: audioTrackLang,
origin: 'EMBEDDED',
embedded: true,
mode: audioTrackId === currentAudioTrack ? 'showing' : 'disabled',
});
}
onPropChanged('audioTracks');
onPropChanged('selectedAudioTrackId');

}
};

// eslint-disable-next-line no-unused-vars
var subscribe = function (cb) {
if (subscribed) return;
subscribed = true;
var answered = false;
luna({
method: 'subscribe',
parameters: {
'mediaId': knownMediaId,
'subscribe': true
}
}, function (result) {
if (result.sourceInfo && !answered) {
answered = true;
var info = result.sourceInfo.programInfo[0];

setSubs(info);

setTracks(info);

unsubscribe(cb);
}

if ((result.error || {}).errorCode) {
answered = true;
// console.error('luna playback error', result.error);
unsubscribe(cb);
// unsubscribe();
// onVideoError();
return;
}

if ((result.unloadCompleted || {}).mediaId === knownMediaId && (result.unloadCompleted || {}).state) {
// strange case where it just.. ends? without ever getting result.sourceInfo
// onEnded();
// console.log('strange case of end');
// unsubscribe(cb);
return;
}

count_message++;

if (count_message === 30 && !answered) {
// cb();
unsubscribe(cb);
}
}, function() { // function(err)
// console.log('luna error log 2');
// console.error(err);
});
};

var unsubscribe = function (cb) {
if (!subscribed) return;
subscribed = false;
luna({
method: 'unsubscribe',
parameters: {
'mediaId': knownMediaId
}
}, function () { // function(result)
// console.log('unsubscribe result', JSON.stringify(result));
cb();
}, function () { // function(err)
// console.log('unsubscribe error', JSON.stringify(err));
cb();
});
cb();
};

// var unload = function (cb) {
// luna({
// method: 'unload',
// parameters: {
// 'mediaId': knownMediaId
// }
// }, cb, cb);
// };

var toggleSubtitles = function (status) {
if (!videoElement.mediaId) return;

Expand Down Expand Up @@ -462,7 +324,7 @@ function WebOsVideo(options) {
currentSubTrack = textTrackId;
}
textTracks.push({
id: textTrackId,
id: 'EMBEDDED_' + textTrackId,
lang: track.lang || 'eng',
label: track.lang || 'eng',
origin: 'EMBEDDED',
Expand All @@ -481,14 +343,15 @@ function WebOsVideo(options) {
currentAudioTrack = audioTrackId;
}
audioTracks.push({
id: audioTrackId,
id: 'EMBEDDED_' + audioTrackId,
lang: track.lang || 'eng',
label: track.lang || 'eng',
origin: 'EMBEDDED',
embedded: true,
mode: audioTrackId === currentAudioTrack ? 'showing' : 'disabled',
});
});
currentAudioTrack = 'EMBEDDED_0';
onPropChanged('audioTracks');
onPropChanged('selectedAudioTrackId');
}
Expand Down Expand Up @@ -1028,11 +891,9 @@ function WebOsVideo(options) {
var initMediaId = function (cb) {
function retrieveMediaId() {
if (videoElement.mediaId) {
knownMediaId = videoElement.mediaId;
clearInterval(timer);
retrieveExtendedTracks();
cb();
// subscribe(cb);
return;
}
count++;
Expand Down

0 comments on commit 88b77e2

Please sign in to comment.