From c123054b5a2a519609dd030721c22cec79b69e36 Mon Sep 17 00:00:00 2001 From: Alexandru Branza Date: Tue, 14 Jan 2025 16:04:19 +0200 Subject: [PATCH] Fix Detecting Platform --- src/StremioVideo/StremioVideo.js | 4 ++++ src/platform.js | 6 ++++++ src/supportsTranscoding.js | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/platform.js diff --git a/src/StremioVideo/StremioVideo.js b/src/StremioVideo/StremioVideo.js index 9428325..246fe5a 100644 --- a/src/StremioVideo/StremioVideo.js +++ b/src/StremioVideo/StremioVideo.js @@ -2,6 +2,7 @@ var EventEmitter = require('eventemitter3'); var cloneDeep = require('lodash.clonedeep'); var deepFreeze = require('deep-freeze'); var selectVideoImplementation = require('./selectVideoImplementation'); +var platform = require('../platform'); var ERROR = require('../error'); function StremioVideo() { @@ -25,6 +26,9 @@ function StremioVideo() { action = deepFreeze(cloneDeep(action)); options = options || {}; if (action.type === 'command' && action.commandName === 'load' && action.commandArgs) { + if (action.commandArgs.platform) { + platform.set(action.commandArgs.platform); + } var Video = selectVideoImplementation(action.commandArgs, options); if (video !== null && video.constructor !== Video) { video.dispatch({ type: 'command', commandName: 'destroy' }); diff --git a/src/platform.js b/src/platform.js new file mode 100644 index 0000000..37d2425 --- /dev/null +++ b/src/platform.js @@ -0,0 +1,6 @@ +var platform = null; + +module.exports = { + set: function(val) { platform = val; }, + get: function() { return platform; } +}; diff --git a/src/supportsTranscoding.js b/src/supportsTranscoding.js index 690fc4a..3970174 100644 --- a/src/supportsTranscoding.js +++ b/src/supportsTranscoding.js @@ -1,5 +1,7 @@ +var platform = require('./platform'); + function supportsTranscoding() { - if (typeof window.tizen !== 'undefined' || typeof window.webOS !== 'undefined' || typeof window.qt !== 'undefined') { + if (['Tizen', 'webOS'].includes(platform.get()) || typeof window.qt !== 'undefined') { return Promise.resolve(false); } return Promise.resolve(true);