Skip to content

Commit

Permalink
Filter Out Unsupported Tracks on LG
Browse files Browse the repository at this point in the history
  • Loading branch information
jaruba committed Jun 7, 2024
1 parent 88b77e2 commit 83b9460
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/WebOsVideo/WebOsVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,47 @@ function stremioSubSizes(size) {
return false;
}

var device = {
unsupportedAudio: ['DTS', 'TRUEHD'],
unsupportedSubs: ['HDMV/PGS']
};

var fetchedDeviceInfo = false;

function retrieveDeviceInfo() {
if (fetchedDeviceInfo) {
return;
}
window.webOS.service.request('luna://com.webos.service.config', {
method: 'getConfigs',
parameters: {
'configNames': [
'tv.model.edidType'
]
},
onSuccess: function (result) {
if (((result || {}).configs || {})['tv.model.edidType']) {
fetchedDeviceInfo = true;
var edidType = result.configs['tv.model.edidType'].toLowerCase();
if (edidType.includes('dts')) {
device.unsupportedAudio = device.unsupportedAudio.filter(function(e) {
return e !== 'DTS';
});
}
if (edidType.includes('truehd')) {
device.unsupportedAudio = device.unsupportedAudio.filter(function(e) {
return e !== 'TRUEHD';
});
}
}
},
onFailure: function (err) {
// eslint-disable-next-line no-console
console.log('could not get deviceInfo', err);
}
});
}

function WebOsVideo(options) {

options = options || {};
Expand Down Expand Up @@ -318,6 +359,9 @@ function WebOsVideo(options) {
}
if (((tracksData || {}).subs || []).length) {
tracksData.subs.forEach(function(track) {
if (device.unsupportedSubs.includes(track.codec || '')) {
return;
}
var textTrackId = nrSubs;
nrSubs++;
if (!currentSubTrack && !textTracks.length) {
Expand All @@ -337,6 +381,9 @@ function WebOsVideo(options) {
}
if (((tracksData || {}).audio || []).length) {
tracksData.audio.forEach(function(track) {
if (device.unsupportedAudio.includes(track.codec || '')) {
return;
}
var audioTrackId = nrAudio;
nrAudio++;
if (!currentAudioTrack && !audioTracks.length) {
Expand Down Expand Up @@ -893,6 +940,7 @@ function WebOsVideo(options) {
if (videoElement.mediaId) {
clearInterval(timer);
retrieveExtendedTracks();
retrieveDeviceInfo();
cb();
return;
}
Expand All @@ -901,6 +949,7 @@ function WebOsVideo(options) {
// console.log('failed to get media id');
clearInterval(timer);
retrieveExtendedTracks();
retrieveDeviceInfo();
cb();
}
}
Expand Down

0 comments on commit 83b9460

Please sign in to comment.