Skip to content

Commit 83b9460

Browse files
committed
Filter Out Unsupported Tracks on LG
1 parent 88b77e2 commit 83b9460

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/WebOsVideo/WebOsVideo.js

+49
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,47 @@ function stremioSubSizes(size) {
136136
return false;
137137
}
138138

139+
var device = {
140+
unsupportedAudio: ['DTS', 'TRUEHD'],
141+
unsupportedSubs: ['HDMV/PGS']
142+
};
143+
144+
var fetchedDeviceInfo = false;
145+
146+
function retrieveDeviceInfo() {
147+
if (fetchedDeviceInfo) {
148+
return;
149+
}
150+
window.webOS.service.request('luna://com.webos.service.config', {
151+
method: 'getConfigs',
152+
parameters: {
153+
'configNames': [
154+
'tv.model.edidType'
155+
]
156+
},
157+
onSuccess: function (result) {
158+
if (((result || {}).configs || {})['tv.model.edidType']) {
159+
fetchedDeviceInfo = true;
160+
var edidType = result.configs['tv.model.edidType'].toLowerCase();
161+
if (edidType.includes('dts')) {
162+
device.unsupportedAudio = device.unsupportedAudio.filter(function(e) {
163+
return e !== 'DTS';
164+
});
165+
}
166+
if (edidType.includes('truehd')) {
167+
device.unsupportedAudio = device.unsupportedAudio.filter(function(e) {
168+
return e !== 'TRUEHD';
169+
});
170+
}
171+
}
172+
},
173+
onFailure: function (err) {
174+
// eslint-disable-next-line no-console
175+
console.log('could not get deviceInfo', err);
176+
}
177+
});
178+
}
179+
139180
function WebOsVideo(options) {
140181

141182
options = options || {};
@@ -318,6 +359,9 @@ function WebOsVideo(options) {
318359
}
319360
if (((tracksData || {}).subs || []).length) {
320361
tracksData.subs.forEach(function(track) {
362+
if (device.unsupportedSubs.includes(track.codec || '')) {
363+
return;
364+
}
321365
var textTrackId = nrSubs;
322366
nrSubs++;
323367
if (!currentSubTrack && !textTracks.length) {
@@ -337,6 +381,9 @@ function WebOsVideo(options) {
337381
}
338382
if (((tracksData || {}).audio || []).length) {
339383
tracksData.audio.forEach(function(track) {
384+
if (device.unsupportedAudio.includes(track.codec || '')) {
385+
return;
386+
}
340387
var audioTrackId = nrAudio;
341388
nrAudio++;
342389
if (!currentAudioTrack && !audioTracks.length) {
@@ -893,6 +940,7 @@ function WebOsVideo(options) {
893940
if (videoElement.mediaId) {
894941
clearInterval(timer);
895942
retrieveExtendedTracks();
943+
retrieveDeviceInfo();
896944
cb();
897945
return;
898946
}
@@ -901,6 +949,7 @@ function WebOsVideo(options) {
901949
// console.log('failed to get media id');
902950
clearInterval(timer);
903951
retrieveExtendedTracks();
952+
retrieveDeviceInfo();
904953
cb();
905954
}
906955
}

0 commit comments

Comments
 (0)