@stremio/stremio-video 0.0.21 → 0.0.23

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.21",
3
+ "version": "0.0.23",
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
  };
@@ -2,6 +2,7 @@ var ChromecastSenderVideo = require('../ChromecastSenderVideo');
2
2
  var ShellVideo = require('../ShellVideo');
3
3
  var HTMLVideo = require('../HTMLVideo');
4
4
  var TizenVideo = require('../TizenVideo');
5
+ var WebOsVideo = require('../WebOsVideo');
5
6
  var IFrameVideo = require('../IFrameVideo');
6
7
  var YouTubeVideo = require('../YouTubeVideo');
7
8
  var withStreamingServer = require('../withStreamingServer');
@@ -23,6 +24,7 @@ function selectVideoImplementation(commandArgs, options) {
23
24
  if (typeof commandArgs.stream.playerFrameUrl === 'string') {
24
25
  return IFrameVideo;
25
26
  }
27
+
26
28
  if (options.shellTransport) {
27
29
  return withStreamingServer(withHTMLSubtitles(ShellVideo));
28
30
  }
@@ -31,10 +33,16 @@ function selectVideoImplementation(commandArgs, options) {
31
33
  if (typeof global.tizen !== 'undefined') {
32
34
  return withStreamingServer(withHTMLSubtitles(TizenVideo));
33
35
  }
36
+ if (typeof global.webOS !== 'undefined') {
37
+ return withStreamingServer(withHTMLSubtitles(WebOsVideo));
38
+ }
34
39
  return withStreamingServer(withHTMLSubtitles(HTMLVideo));
35
40
  }
36
41
 
37
42
  if (typeof commandArgs.stream.url === 'string') {
43
+ if (typeof global.webOS !== 'undefined') {
44
+ return withHTMLSubtitles(WebOsVideo);
45
+ }
38
46
  if (typeof global.tizen !== 'undefined') {
39
47
  return withHTMLSubtitles(TizenVideo);
40
48
  }