diff --git a/src/routes/Player/Video/Video.js b/src/routes/Player/Video/Video.js index af1ee9e26..4f1f9306c 100644 --- a/src/routes/Player/Video/Video.js +++ b/src/routes/Player/Video/Video.js @@ -21,7 +21,7 @@ class Video extends Component { this.dispatch('command', 'destroy'); } - selectVideoImplementation = (stream, extra) => { + selectVideoImplementation = (stream, options) => { if (stream.ytId) { return YouTubeVideo; } else { @@ -34,7 +34,7 @@ class Video extends Component { const Video = this.selectVideoImplementation(args[2], args[3]); if (this.video === null || this.video.constructor !== Video) { this.dispatch('command', 'destroy'); - this.video = new Video(this.containerRef.current); + this.video = new Video({ containerElement: this.containerRef.current }); this.video.on('ended', this.props.onEnded); this.video.on('error', this.props.onError); this.video.on('propValue', this.props.onPropValue); diff --git a/src/routes/Player/Video/stremio-video/HTMLVideo.js b/src/routes/Player/Video/stremio-video/HTMLVideo.js index 6aa038326..50512864c 100644 --- a/src/routes/Player/Video/stremio-video/HTMLVideo.js +++ b/src/routes/Player/Video/stremio-video/HTMLVideo.js @@ -1,9 +1,10 @@ var EventEmitter = require('events'); var HTMLSubtitles = require('./HTMLSubtitles'); -function HTMLVideo(containerElement) { +function HTMLVideo(options) { + var containerElement = options && options.containerElement; if (!(containerElement instanceof HTMLElement) || !containerElement.hasAttribute('id')) { - throw new Error('Instance of HTMLElement with id attribute required as a first argument'); + throw new Error('Instance of HTMLElement with id attribute required'); } var self = this; diff --git a/src/routes/Player/Video/stremio-video/YouTubeVideo.js b/src/routes/Player/Video/stremio-video/YouTubeVideo.js index fac988543..07825e014 100644 --- a/src/routes/Player/Video/stremio-video/YouTubeVideo.js +++ b/src/routes/Player/Video/stremio-video/YouTubeVideo.js @@ -1,9 +1,10 @@ var EventEmitter = require('events'); var HTMLSubtitles = require('./HTMLSubtitles'); -function YouTubeVideo(containerElement) { +function YouTubeVideo(options) { + var containerElement = options && options.containerElement; if (!(containerElement instanceof HTMLElement) || !containerElement.hasAttribute('id')) { - throw new Error('Instance of HTMLElement with id attribute required as a first argument'); + throw new Error('Instance of HTMLElement with id attribute required'); } var self = this; diff --git a/src/services/index.js b/src/services/index.js deleted file mode 100644 index 1aa7e8c20..000000000 --- a/src/services/index.js +++ /dev/null @@ -1,5 +0,0 @@ -const ipc = require('./ipc'); - -module.exports = { - ipc -}; diff --git a/src/services/ipc.js b/src/services/ipc.js deleted file mode 100644 index 5ff4b2714..000000000 --- a/src/services/ipc.js +++ /dev/null @@ -1,54 +0,0 @@ -var events = require("events"); - -var ipc = new events.EventEmitter(); - -ipc.props = { }; -ipc.send = function() { }; -ipc.isDesktop = false; - -// New method of communication -window.initShellComm = function() { - var transport = window.qt && window.qt.webChannelTransport - if (! transport) throw "no viable transport found (qt.webChannelTransport)" - - ipc.isDesktop = true; - - var QtMsgTypes = { signal: 1, propertyUpdate: 2, init: 3, idle: 4, debug: 5, invokeMethod: 6, connectToSignal: 7, disconnectFromSignal: 8, setProperty: 9, response: 10 }; - var QtObjId = "transport"; // the ID of our transport object - - var id = 0; - function send(msg) { - msg.id = id++; - transport.send(JSON.stringify(msg)) - } - - transport.onmessage = function(message) { - var msg = JSON.parse(message.data) - - if (msg.id === 0) { - var obj = msg.data[QtObjId] - - obj.properties.slice(1).forEach(function(prop) { - ipc.props[prop[1]] = prop[3] - }) - ipc.emit("received-props", ipc.props) - - obj.signals.forEach(function(sig) { - send({ type: QtMsgTypes.connectToSignal, object: QtObjId, signal: sig[1] }) - }) - - var onEvent = obj.methods.filter(function(x) { return x[0] === "onEvent" })[0] - - ipc.send = function(ev, args) { - send({ type: QtMsgTypes.invokeMethod, object: QtObjId, method: onEvent[1], args: [ev, args || { }] }) - } - ipc.send("app-ready", { }) // signal that we're ready to take events - } - - if (msg.object == QtObjId && msg.type === QtMsgTypes.signal) ipc.emit(msg.args[0], msg.args[1]) - } - - send({ type: QtMsgTypes.init }) -} - -module.exports = ipc; \ No newline at end of file