@stremio/stremio-video 0.0.21 → 0.0.22
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stremio/stremio-video",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"description": "Abstraction layer on top of different media players",
|
|
5
5
|
"author": "Smart Code OOD",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
"lint": "eslint src"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
+
"buffer": "6.0.3",
|
|
17
|
+
"color": "4.2.3",
|
|
16
18
|
"deep-freeze": "0.0.1",
|
|
17
19
|
"eventemitter3": "4.0.7",
|
|
18
20
|
"hat": "0.0.3",
|
|
@@ -21,8 +23,7 @@
|
|
|
21
23
|
"magnet-uri": "6.2.0",
|
|
22
24
|
"url": "0.11.0",
|
|
23
25
|
"video-name-parser": "1.4.6",
|
|
24
|
-
"vtt.js": "github:jaruba/vtt.js#e4f5f5603730866bacb174a93f51b734c9f29e6a"
|
|
25
|
-
"color": "4.2.3"
|
|
26
|
+
"vtt.js": "github:jaruba/vtt.js#e4f5f5603730866bacb174a93f51b734c9f29e6a"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"eslint": "7.32.0"
|
|
@@ -45,6 +45,7 @@ function ChromecastSenderVideo(options) {
|
|
|
45
45
|
var destroyed = false;
|
|
46
46
|
var observedProps = {
|
|
47
47
|
stream: false,
|
|
48
|
+
loaded: false,
|
|
48
49
|
paused: false,
|
|
49
50
|
time: false,
|
|
50
51
|
duration: false,
|
|
@@ -107,6 +108,7 @@ function ChromecastSenderVideo(options) {
|
|
|
107
108
|
case 'destroy': {
|
|
108
109
|
destroyed = true;
|
|
109
110
|
onPropChanged('stream', null);
|
|
111
|
+
onPropChanged('loaded', null);
|
|
110
112
|
onPropChanged('paused', null);
|
|
111
113
|
onPropChanged('time', null);
|
|
112
114
|
onPropChanged('duration', null);
|
|
@@ -188,7 +190,7 @@ ChromecastSenderVideo.canPlayStream = function() {
|
|
|
188
190
|
ChromecastSenderVideo.manifest = {
|
|
189
191
|
name: 'ChromecastSenderVideo',
|
|
190
192
|
external: true,
|
|
191
|
-
props: ['stream', 'paused', 'time', 'duration', 'buffering', 'buffered', 'audioTracks', 'selectedAudioTrackId', 'subtitlesTracks', 'selectedSubtitlesTrackId', 'subtitlesOffset', 'subtitlesSize', 'subtitlesTextColor', 'subtitlesBackgroundColor', 'subtitlesOutlineColor', 'volume', 'muted', 'playbackSpeed', 'extraSubtitlesTracks', 'selectedExtraSubtitlesTrackId', 'extraSubtitlesDelay', 'extraSubtitlesSize', 'extraSubtitlesOffset', 'extraSubtitlesTextColor', 'extraSubtitlesBackgroundColor', 'extraSubtitlesOutlineColor'],
|
|
193
|
+
props: ['stream', 'loaded', 'paused', 'time', 'duration', 'buffering', 'buffered', 'audioTracks', 'selectedAudioTrackId', 'subtitlesTracks', 'selectedSubtitlesTrackId', 'subtitlesOffset', 'subtitlesSize', 'subtitlesTextColor', 'subtitlesBackgroundColor', 'subtitlesOutlineColor', 'volume', 'muted', 'playbackSpeed', 'extraSubtitlesTracks', 'selectedExtraSubtitlesTrackId', 'extraSubtitlesDelay', 'extraSubtitlesSize', 'extraSubtitlesOffset', 'extraSubtitlesTextColor', 'extraSubtitlesBackgroundColor', 'extraSubtitlesOutlineColor'],
|
|
192
194
|
commands: ['load', 'unload', 'destroy', 'addExtraSubtitlesTracks'],
|
|
193
195
|
events: ['propValue', 'propChanged', 'ended', 'error', 'subtitlesTrackLoaded', 'audioTrackLoaded', 'extraSubtitlesTrackLoaded', 'implementationChanged']
|
|
194
196
|
};
|
|
@@ -47,10 +47,12 @@ function HTMLVideo(options) {
|
|
|
47
47
|
onPropChanged('buffered');
|
|
48
48
|
};
|
|
49
49
|
videoElement.onseeking = function() {
|
|
50
|
+
onPropChanged('time');
|
|
50
51
|
onPropChanged('buffering');
|
|
51
52
|
onPropChanged('buffered');
|
|
52
53
|
};
|
|
53
54
|
videoElement.onseeked = function() {
|
|
55
|
+
onPropChanged('time');
|
|
54
56
|
onPropChanged('buffering');
|
|
55
57
|
onPropChanged('buffered');
|
|
56
58
|
};
|
|
@@ -59,6 +61,7 @@ function HTMLVideo(options) {
|
|
|
59
61
|
onPropChanged('buffered');
|
|
60
62
|
};
|
|
61
63
|
videoElement.onplaying = function() {
|
|
64
|
+
onPropChanged('time');
|
|
62
65
|
onPropChanged('buffering');
|
|
63
66
|
onPropChanged('buffered');
|
|
64
67
|
};
|
|
@@ -70,6 +73,9 @@ function HTMLVideo(options) {
|
|
|
70
73
|
onPropChanged('buffering');
|
|
71
74
|
onPropChanged('buffered');
|
|
72
75
|
};
|
|
76
|
+
videoElement.onloadedmetadata = function() {
|
|
77
|
+
onPropChanged('loaded');
|
|
78
|
+
};
|
|
73
79
|
videoElement.onloadeddata = function() {
|
|
74
80
|
onPropChanged('buffering');
|
|
75
81
|
onPropChanged('buffered');
|
|
@@ -98,6 +104,7 @@ function HTMLVideo(options) {
|
|
|
98
104
|
var subtitlesOffset = 0;
|
|
99
105
|
var observedProps = {
|
|
100
106
|
stream: false,
|
|
107
|
+
loaded: false,
|
|
101
108
|
paused: false,
|
|
102
109
|
time: false,
|
|
103
110
|
duration: false,
|
|
@@ -122,6 +129,13 @@ function HTMLVideo(options) {
|
|
|
122
129
|
case 'stream': {
|
|
123
130
|
return stream;
|
|
124
131
|
}
|
|
132
|
+
case 'loaded': {
|
|
133
|
+
if (stream === null) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return videoElement.readyState >= videoElement.HAVE_METADATA;
|
|
138
|
+
}
|
|
125
139
|
case 'paused': {
|
|
126
140
|
if (stream === null) {
|
|
127
141
|
return null;
|
|
@@ -355,6 +369,7 @@ function HTMLVideo(options) {
|
|
|
355
369
|
case 'paused': {
|
|
356
370
|
if (stream !== null) {
|
|
357
371
|
propValue ? videoElement.pause() : videoElement.play();
|
|
372
|
+
onPropChanged('paused');
|
|
358
373
|
}
|
|
359
374
|
|
|
360
375
|
break;
|
|
@@ -362,6 +377,7 @@ function HTMLVideo(options) {
|
|
|
362
377
|
case 'time': {
|
|
363
378
|
if (stream !== null && propValue !== null && isFinite(propValue)) {
|
|
364
379
|
videoElement.currentTime = parseInt(propValue, 10) / 1000;
|
|
380
|
+
onPropChanged('time');
|
|
365
381
|
}
|
|
366
382
|
|
|
367
383
|
break;
|
|
@@ -377,6 +393,7 @@ function HTMLVideo(options) {
|
|
|
377
393
|
return track.id === propValue;
|
|
378
394
|
});
|
|
379
395
|
if (selecterdSubtitlesTrack) {
|
|
396
|
+
onPropChanged('selectedSubtitlesTrackId');
|
|
380
397
|
events.emit('subtitlesTrackLoaded', selecterdSubtitlesTrack);
|
|
381
398
|
}
|
|
382
399
|
}
|
|
@@ -450,6 +467,7 @@ function HTMLVideo(options) {
|
|
|
450
467
|
});
|
|
451
468
|
hls.audioTrack = selecterdAudioTrack ? parseInt(selecterdAudioTrack.id.split('_').pop(), 10) : -1;
|
|
452
469
|
if (selecterdAudioTrack) {
|
|
470
|
+
onPropChanged('selectedAudioTrackId');
|
|
453
471
|
events.emit('audioTrackLoaded', selecterdAudioTrack);
|
|
454
472
|
}
|
|
455
473
|
}
|
|
@@ -460,17 +478,21 @@ function HTMLVideo(options) {
|
|
|
460
478
|
if (propValue !== null && isFinite(propValue)) {
|
|
461
479
|
videoElement.muted = false;
|
|
462
480
|
videoElement.volume = Math.max(0, Math.min(100, parseInt(propValue, 10))) / 100;
|
|
481
|
+
onPropChanged('muted');
|
|
482
|
+
onPropChanged('volume');
|
|
463
483
|
}
|
|
464
484
|
|
|
465
485
|
break;
|
|
466
486
|
}
|
|
467
487
|
case 'muted': {
|
|
468
488
|
videoElement.muted = !!propValue;
|
|
489
|
+
onPropChanged('muted');
|
|
469
490
|
break;
|
|
470
491
|
}
|
|
471
492
|
case 'playbackSpeed': {
|
|
472
493
|
if (propValue !== null && isFinite(propValue)) {
|
|
473
494
|
videoElement.playbackRate = parseFloat(propValue);
|
|
495
|
+
onPropChanged('playbackSpeed');
|
|
474
496
|
}
|
|
475
497
|
|
|
476
498
|
break;
|
|
@@ -484,6 +506,7 @@ function HTMLVideo(options) {
|
|
|
484
506
|
if (commandArgs && commandArgs.stream && typeof commandArgs.stream.url === 'string') {
|
|
485
507
|
stream = commandArgs.stream;
|
|
486
508
|
onPropChanged('stream');
|
|
509
|
+
onPropChanged('loaded');
|
|
487
510
|
videoElement.autoplay = typeof commandArgs.autoplay === 'boolean' ? commandArgs.autoplay : true;
|
|
488
511
|
videoElement.currentTime = commandArgs.time !== null && isFinite(commandArgs.time) ? parseInt(commandArgs.time, 10) / 1000 : 0;
|
|
489
512
|
onPropChanged('paused');
|
|
@@ -547,6 +570,7 @@ function HTMLVideo(options) {
|
|
|
547
570
|
videoElement.load();
|
|
548
571
|
videoElement.currentTime = 0;
|
|
549
572
|
onPropChanged('stream');
|
|
573
|
+
onPropChanged('loaded');
|
|
550
574
|
onPropChanged('paused');
|
|
551
575
|
onPropChanged('time');
|
|
552
576
|
onPropChanged('duration');
|
|
@@ -646,7 +670,7 @@ HTMLVideo.canPlayStream = function(stream) {
|
|
|
646
670
|
HTMLVideo.manifest = {
|
|
647
671
|
name: 'HTMLVideo',
|
|
648
672
|
external: false,
|
|
649
|
-
props: ['stream', 'paused', 'time', 'duration', 'buffering', 'buffered', 'audioTracks', 'selectedAudioTrackId', 'subtitlesTracks', 'selectedSubtitlesTrackId', 'subtitlesOffset', 'subtitlesSize', 'subtitlesTextColor', 'subtitlesBackgroundColor', 'subtitlesOutlineColor', 'volume', 'muted', 'playbackSpeed'],
|
|
673
|
+
props: ['stream', 'loaded', 'paused', 'time', 'duration', 'buffering', 'buffered', 'audioTracks', 'selectedAudioTrackId', 'subtitlesTracks', 'selectedSubtitlesTrackId', 'subtitlesOffset', 'subtitlesSize', 'subtitlesTextColor', 'subtitlesBackgroundColor', 'subtitlesOutlineColor', 'volume', 'muted', 'playbackSpeed'],
|
|
650
674
|
commands: ['load', 'unload', 'destroy'],
|
|
651
675
|
events: ['propValue', 'propChanged', 'ended', 'error', 'subtitlesTrackLoaded', 'audioTrackLoaded']
|
|
652
676
|
};
|
|
@@ -24,6 +24,7 @@ function IFrameVideo(options) {
|
|
|
24
24
|
var destroyed = false;
|
|
25
25
|
var observedProps = {
|
|
26
26
|
stream: false,
|
|
27
|
+
loaded: false,
|
|
27
28
|
paused: false,
|
|
28
29
|
time: false,
|
|
29
30
|
duration: false,
|
|
@@ -95,6 +96,7 @@ function IFrameVideo(options) {
|
|
|
95
96
|
iframeElement.onload = null;
|
|
96
97
|
iframeElement.removeAttribute('src');
|
|
97
98
|
onPropChanged('stream', null);
|
|
99
|
+
onPropChanged('loaded', null);
|
|
98
100
|
onPropChanged('paused', null);
|
|
99
101
|
onPropChanged('time', null);
|
|
100
102
|
onPropChanged('duration', null);
|
|
@@ -108,15 +110,6 @@ function IFrameVideo(options) {
|
|
|
108
110
|
case 'destroy': {
|
|
109
111
|
command('unload');
|
|
110
112
|
destroyed = true;
|
|
111
|
-
onPropChanged('stream', null);
|
|
112
|
-
onPropChanged('paused', null);
|
|
113
|
-
onPropChanged('time', null);
|
|
114
|
-
onPropChanged('duration', null);
|
|
115
|
-
onPropChanged('buffering', null);
|
|
116
|
-
onPropChanged('buffered', null);
|
|
117
|
-
onPropChanged('volume', null);
|
|
118
|
-
onPropChanged('muted', null);
|
|
119
|
-
onPropChanged('playbackSpeed', null);
|
|
120
113
|
events.removeAllListeners();
|
|
121
114
|
containerElement.removeChild(iframeElement);
|
|
122
115
|
return true;
|
|
@@ -169,7 +162,7 @@ IFrameVideo.canPlayStream = function(stream) {
|
|
|
169
162
|
IFrameVideo.manifest = {
|
|
170
163
|
name: 'IFrameVideo',
|
|
171
164
|
external: true,
|
|
172
|
-
props: ['stream', 'paused', 'time', 'duration', 'buffering', 'buffered', 'audioTracks', 'selectedAudioTrackId', 'subtitlesTracks', 'selectedSubtitlesTrackId', 'subtitlesOffset', 'subtitlesSize', 'subtitlesTextColor', 'subtitlesBackgroundColor', 'subtitlesOutlineColor', 'volume', 'muted', 'playbackSpeed', 'extraSubtitlesTracks', 'selectedExtraSubtitlesTrackId', 'extraSubtitlesDelay', 'extraSubtitlesSize', 'extraSubtitlesOffset', 'extraSubtitlesTextColor', 'extraSubtitlesBackgroundColor', 'extraSubtitlesOutlineColor'],
|
|
165
|
+
props: ['stream', 'loaded', 'paused', 'time', 'duration', 'buffering', 'buffered', 'audioTracks', 'selectedAudioTrackId', 'subtitlesTracks', 'selectedSubtitlesTrackId', 'subtitlesOffset', 'subtitlesSize', 'subtitlesTextColor', 'subtitlesBackgroundColor', 'subtitlesOutlineColor', 'volume', 'muted', 'playbackSpeed', 'extraSubtitlesTracks', 'selectedExtraSubtitlesTrackId', 'extraSubtitlesDelay', 'extraSubtitlesSize', 'extraSubtitlesOffset', 'extraSubtitlesTextColor', 'extraSubtitlesBackgroundColor', 'extraSubtitlesOutlineColor'],
|
|
173
166
|
commands: ['load', 'unload', 'destroy', 'addExtraSubtitlesTracks'],
|
|
174
167
|
events: ['propValue', 'propChanged', 'ended', 'error', 'subtitlesTrackLoaded', 'audioTrackLoaded', 'extraSubtitlesTrackLoaded', 'implementationChanged']
|
|
175
168
|
};
|
|
@@ -39,6 +39,7 @@ function YouTubeVideo(options) {
|
|
|
39
39
|
var selectedSubtitlesTrackId = null;
|
|
40
40
|
var observedProps = {
|
|
41
41
|
stream: false,
|
|
42
|
+
loaded: false,
|
|
42
43
|
paused: false,
|
|
43
44
|
time: false,
|
|
44
45
|
duration: false,
|
|
@@ -190,6 +191,13 @@ function YouTubeVideo(options) {
|
|
|
190
191
|
case 'stream': {
|
|
191
192
|
return stream;
|
|
192
193
|
}
|
|
194
|
+
case 'loaded': {
|
|
195
|
+
if (stream === null) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
193
201
|
case 'paused': {
|
|
194
202
|
if (stream === null || typeof video.getPlayerState !== 'function') {
|
|
195
203
|
return null;
|
|
@@ -360,6 +368,7 @@ function YouTubeVideo(options) {
|
|
|
360
368
|
if (ready) {
|
|
361
369
|
stream = commandArgs.stream;
|
|
362
370
|
onPropChanged('stream');
|
|
371
|
+
onPropChanged('loaded');
|
|
363
372
|
var autoplay = typeof commandArgs.autoplay === 'boolean' ? commandArgs.autoplay : true;
|
|
364
373
|
var time = commandArgs.time !== null && isFinite(commandArgs.time) ? parseInt(commandArgs.time, 10) / 1000 : 0;
|
|
365
374
|
if (autoplay && typeof video.loadVideoById === 'function') {
|
|
@@ -397,6 +406,7 @@ function YouTubeVideo(options) {
|
|
|
397
406
|
pendingLoadArgs = null;
|
|
398
407
|
stream = null;
|
|
399
408
|
onPropChanged('stream');
|
|
409
|
+
onPropChanged('loaded');
|
|
400
410
|
selectedSubtitlesTrackId = null;
|
|
401
411
|
if (ready && typeof video.stopVideo === 'function') {
|
|
402
412
|
video.stopVideo();
|
|
@@ -467,7 +477,7 @@ YouTubeVideo.canPlayStream = function(stream) {
|
|
|
467
477
|
YouTubeVideo.manifest = {
|
|
468
478
|
name: 'YouTubeVideo',
|
|
469
479
|
external: false,
|
|
470
|
-
props: ['stream', 'paused', 'time', 'duration', 'buffering', 'volume', 'muted', 'subtitlesTracks', 'selectedSubtitlesTrackId'],
|
|
480
|
+
props: ['stream', 'loaded', 'paused', 'time', 'duration', 'buffering', 'volume', 'muted', 'subtitlesTracks', 'selectedSubtitlesTrackId'],
|
|
471
481
|
commands: ['load', 'unload', 'destroy'],
|
|
472
482
|
events: ['propValue', 'propChanged', 'ended', 'error', 'subtitlesTrackLoaded']
|
|
473
483
|
};
|