@stremio/stremio-video 0.0.18 → 0.0.20-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -74,8 +74,7 @@ function ChromecastSenderVideo(options) {
|
|
|
74
74
|
function onTransportError(error, action) {
|
|
75
75
|
events.emit('error', Object.assign({}, ERROR.CHROMECAST_SENDER_VIDEO.MESSAGE_SEND_FAILED, {
|
|
76
76
|
error: error,
|
|
77
|
-
action: action
|
|
78
|
-
message: 'Chromecast transport error'
|
|
77
|
+
action: action
|
|
79
78
|
}));
|
|
80
79
|
}
|
|
81
80
|
function onMessage(message) {
|
|
@@ -85,14 +84,14 @@ function ChromecastSenderVideo(options) {
|
|
|
85
84
|
} catch (error) {
|
|
86
85
|
events.emit('error', Object.assign({}, ERROR.CHROMECAST_SENDER_VIDEO.INVALID_MESSAGE_RECEIVED, {
|
|
87
86
|
error: error,
|
|
88
|
-
|
|
87
|
+
args: message
|
|
89
88
|
}));
|
|
90
89
|
return;
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
if (!parsedMessage || typeof parsedMessage.event !== 'string') {
|
|
94
93
|
events.emit('error', Object.assign({}, ERROR.CHROMECAST_SENDER_VIDEO.INVALID_MESSAGE_RECEIVED, {
|
|
95
|
-
|
|
94
|
+
args: message
|
|
96
95
|
}));
|
|
97
96
|
return;
|
|
98
97
|
}
|
|
@@ -22,7 +22,6 @@ function HTMLVideo(options) {
|
|
|
22
22
|
videoElement.style.width = '100%';
|
|
23
23
|
videoElement.style.height = '100%';
|
|
24
24
|
videoElement.style.backgroundColor = 'black';
|
|
25
|
-
videoElement.crossOrigin = 'anonymous';
|
|
26
25
|
videoElement.controls = false;
|
|
27
26
|
videoElement.onerror = function() {
|
|
28
27
|
onVideoError();
|
|
@@ -73,18 +73,26 @@ function IFrameVideo(options) {
|
|
|
73
73
|
command('unload');
|
|
74
74
|
if (commandArgs && commandArgs.stream && typeof commandArgs.stream.playerFrameUrl === 'string') {
|
|
75
75
|
window.addEventListener('message', onMessage, false);
|
|
76
|
+
iframeElement.onload = function() {
|
|
77
|
+
sendMessage({
|
|
78
|
+
type: 'command',
|
|
79
|
+
commandName: commandName,
|
|
80
|
+
commandArgs: commandArgs
|
|
81
|
+
});
|
|
82
|
+
};
|
|
76
83
|
iframeElement.src = commandArgs.stream.playerFrameUrl;
|
|
77
|
-
return false;
|
|
78
84
|
} else {
|
|
79
85
|
onError(Object.assign({}, ERROR.UNSUPPORTED_STREAM, {
|
|
80
86
|
critical: true,
|
|
81
87
|
stream: commandArgs ? commandArgs.stream : null
|
|
82
88
|
}));
|
|
83
|
-
return true;
|
|
84
89
|
}
|
|
90
|
+
|
|
91
|
+
return true;
|
|
85
92
|
}
|
|
86
93
|
case 'unload': {
|
|
87
94
|
window.removeEventListener('message', onMessage);
|
|
95
|
+
iframeElement.onload = null;
|
|
88
96
|
iframeElement.removeAttribute('src');
|
|
89
97
|
onPropChanged('stream', null);
|
|
90
98
|
onPropChanged('paused', null);
|
|
@@ -82,8 +82,7 @@ function StremioVideo() {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
if (action.type === 'command' && action.commandName === 'destroy') {
|
|
85
|
-
|
|
86
|
-
events.removeAllListeners();
|
|
85
|
+
video = null;
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
return;
|
|
@@ -91,6 +90,15 @@ function StremioVideo() {
|
|
|
91
90
|
|
|
92
91
|
throw new Error('Invalid action dispatched: ' + JSON.stringify(action));
|
|
93
92
|
};
|
|
93
|
+
this.destroy = function() {
|
|
94
|
+
destroyed = true;
|
|
95
|
+
if (video !== null) {
|
|
96
|
+
video.dispatch({ type: 'command', commandName: 'destroy' });
|
|
97
|
+
video = null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
events.removeAllListeners();
|
|
101
|
+
};
|
|
94
102
|
}
|
|
95
103
|
|
|
96
104
|
module.exports = StremioVideo;
|