@stremio/stremio-video 0.0.45 → 0.0.46
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
|
@@ -6,6 +6,7 @@ var ERROR = require('../error');
|
|
|
6
6
|
var SUBS_SCALE_FACTOR = 0.0066;
|
|
7
7
|
|
|
8
8
|
var stremioToMPVProps = {
|
|
9
|
+
'loaded': 'loaded',
|
|
9
10
|
'stream': null,
|
|
10
11
|
'paused': 'pause',
|
|
11
12
|
'time': 'time-pos',
|
|
@@ -24,17 +25,35 @@ var stremioToMPVProps = {
|
|
|
24
25
|
'subtitlesOutlineColor': 'sub-border-color',
|
|
25
26
|
};
|
|
26
27
|
|
|
28
|
+
function parseVersion(version) {
|
|
29
|
+
return version.split('.').slice(0, 2).map(function (v) { return parseInt(v); });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function versionGTE(a, b) {
|
|
33
|
+
var versionA = parseVersion(a);
|
|
34
|
+
var versionB = parseVersion(b);
|
|
35
|
+
if (versionA[0] > versionB[0]) return true;
|
|
36
|
+
if (versionA[0] < versionB[0]) return false;
|
|
37
|
+
return versionA[1] >= versionB[1];
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
function ShellVideo(options) {
|
|
28
41
|
options = options || {};
|
|
29
42
|
|
|
30
43
|
var ipc = options.shellTransport;
|
|
31
|
-
|
|
44
|
+
var observedProps = {};
|
|
45
|
+
var props = {};
|
|
32
46
|
var stremioProps = {};
|
|
33
47
|
Object.keys(stremioToMPVProps).forEach(function(key) {
|
|
34
48
|
if(stremioToMPVProps[key]) {
|
|
35
49
|
stremioProps[stremioToMPVProps[key]] = key;
|
|
36
50
|
}
|
|
37
51
|
});
|
|
52
|
+
var resolveMPVVersion;
|
|
53
|
+
var waitForMPVVersion = new Promise(function (resolve) {
|
|
54
|
+
resolveMPVVersion = resolve;
|
|
55
|
+
});
|
|
56
|
+
command('unload');
|
|
38
57
|
|
|
39
58
|
ipc.send('mpv-command', ['stop']);
|
|
40
59
|
ipc.send('mpv-observe-prop', 'path');
|
|
@@ -66,13 +85,9 @@ function ShellVideo(options) {
|
|
|
66
85
|
var events = new EventEmitter();
|
|
67
86
|
var destroyed = false;
|
|
68
87
|
var stream = null;
|
|
69
|
-
// var selectedSubtitlesTrackId = null;
|
|
70
|
-
var observedProps = {};
|
|
71
|
-
var continueFrom = 0;
|
|
72
88
|
|
|
73
89
|
var avgDuration = 0;
|
|
74
90
|
var minClipDuration = 30;
|
|
75
|
-
var props = { };
|
|
76
91
|
|
|
77
92
|
function setBackground(visible) {
|
|
78
93
|
// This is a bit of a hack but there is no better way so far
|
|
@@ -93,6 +108,9 @@ function ShellVideo(options) {
|
|
|
93
108
|
ipc.on('mpv-prop-change', function(args) {
|
|
94
109
|
switch (args.name) {
|
|
95
110
|
case 'mpv-version':
|
|
111
|
+
resolveMPVVersion(args.data);
|
|
112
|
+
props[args.name] = logProp(args);
|
|
113
|
+
break;
|
|
96
114
|
case 'ffmpeg-version': {
|
|
97
115
|
props[args.name] = logProp(args);
|
|
98
116
|
break;
|
|
@@ -111,15 +129,12 @@ function ShellVideo(options) {
|
|
|
111
129
|
// for bitwise maths so the maximum supported video duration is 1073741823 (2 ^ 30 - 1)
|
|
112
130
|
// which is around 34 years of playback time.
|
|
113
131
|
avgDuration = avgDuration ? (avgDuration + intDuration) >> 1 : intDuration;
|
|
132
|
+
props.loaded = intDuration > 0;
|
|
133
|
+
if(props.loaded) onPropChanged('loaded');
|
|
114
134
|
break;
|
|
115
135
|
}
|
|
116
136
|
case 'time-pos': {
|
|
117
137
|
props[args.name] = Math.round(args.data*1000);
|
|
118
|
-
if(continueFrom) {
|
|
119
|
-
ipc.send('mpv-set-prop', ['time-pos', continueFrom]);
|
|
120
|
-
props[args.name] = Math.round(continueFrom);
|
|
121
|
-
continueFrom = 0;
|
|
122
|
-
}
|
|
123
138
|
break;
|
|
124
139
|
}
|
|
125
140
|
case 'sub-scale': {
|
|
@@ -306,60 +321,72 @@ function ShellVideo(options) {
|
|
|
306
321
|
case 'load': {
|
|
307
322
|
command('unload');
|
|
308
323
|
if (commandArgs && commandArgs.stream && typeof commandArgs.stream.url === 'string') {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
324
|
+
waitForMPVVersion.then(function (mpvVersion) {
|
|
325
|
+
stream = commandArgs.stream;
|
|
326
|
+
onPropChanged('stream');
|
|
312
327
|
|
|
313
|
-
|
|
328
|
+
setBackground(false);
|
|
314
329
|
|
|
315
|
-
|
|
330
|
+
ipc.send('mpv-set-prop', ['no-sub-ass']);
|
|
316
331
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
332
|
+
// opengl-cb is an alias for the new name "libmpv", as shown in mpv's video/out/vo.c aliases
|
|
333
|
+
// opengl is an alias for the new name "gpu"
|
|
334
|
+
// When on Windows we use d3d for the rendering in separate window
|
|
335
|
+
var windowRenderer = navigator.platform === 'Win32' ? 'direct3d' : 'opengl';
|
|
336
|
+
var videoOutput = options.mpvSeparateWindow ? windowRenderer : 'opengl-cb';
|
|
337
|
+
var separateWindow = options.mpvSeparateWindow ? 'yes' : 'no';
|
|
338
|
+
ipc.send('mpv-set-prop', ['vo', videoOutput]);
|
|
339
|
+
ipc.send('mpv-set-prop', ['osc', separateWindow]);
|
|
340
|
+
ipc.send('mpv-set-prop', ['input-defalt-bindings', separateWindow]);
|
|
341
|
+
ipc.send('mpv-set-prop', ['input-vo-keyboard', separateWindow]);
|
|
327
342
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
343
|
+
var startAt = Math.floor(parseInt(commandArgs.time, 10) / 1000) || 0;
|
|
344
|
+
if (startAt !== 0) {
|
|
345
|
+
if (versionGTE(mpvVersion, '0.39')) {
|
|
346
|
+
ipc.send('mpv-command', ['loadfile', stream.url, 'replace', '-1', 'start=+' + startAt]);
|
|
347
|
+
} else {
|
|
348
|
+
ipc.send('mpv-command', ['loadfile', stream.url, 'replace', 'start=+' + startAt]);
|
|
349
|
+
}
|
|
350
|
+
} else {
|
|
351
|
+
ipc.send('mpv-command', ['loadfile', stream.url]);
|
|
352
|
+
}
|
|
353
|
+
ipc.send('mpv-set-prop', ['pause', false]);
|
|
354
|
+
ipc.send('mpv-set-prop', ['speed', props.speed]);
|
|
355
|
+
ipc.send('mpv-set-prop', ['aid', props.aid]);
|
|
356
|
+
ipc.send('mpv-set-prop', ['mute', 'no']);
|
|
333
357
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
358
|
+
onPropChanged('paused');
|
|
359
|
+
onPropChanged('time');
|
|
360
|
+
onPropChanged('duration');
|
|
361
|
+
onPropChanged('buffering');
|
|
362
|
+
onPropChanged('volume');
|
|
363
|
+
onPropChanged('muted');
|
|
364
|
+
onPropChanged('subtitlesTracks');
|
|
365
|
+
onPropChanged('selectedSubtitlesTrackId');
|
|
366
|
+
});
|
|
342
367
|
} else {
|
|
343
368
|
onError(Object.assign({}, ERROR.UNSUPPORTED_STREAM, {
|
|
344
369
|
critical: true,
|
|
345
370
|
stream: commandArgs ? commandArgs.stream : null
|
|
346
371
|
}));
|
|
347
372
|
}
|
|
348
|
-
|
|
349
373
|
break;
|
|
350
374
|
}
|
|
351
375
|
case 'unload': {
|
|
352
376
|
props = {
|
|
377
|
+
loaded: false,
|
|
378
|
+
pause: false,
|
|
353
379
|
mute: false,
|
|
354
380
|
speed: 1,
|
|
355
381
|
subtitlesTracks: [],
|
|
356
|
-
|
|
382
|
+
audioTracks: [],
|
|
383
|
+
buffering: false,
|
|
357
384
|
aid: null,
|
|
358
385
|
sid: null,
|
|
359
386
|
};
|
|
360
|
-
continueFrom = 0;
|
|
361
387
|
avgDuration = 0;
|
|
362
388
|
ipc.send('mpv-command', ['stop']);
|
|
389
|
+
onPropChanged('loaded');
|
|
363
390
|
onPropChanged('stream');
|
|
364
391
|
onPropChanged('paused');
|
|
365
392
|
onPropChanged('time');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function supportsTranscoding() {
|
|
2
|
-
if (typeof global.tizen !== 'undefined' || typeof global.webOS !== 'undefined') {
|
|
2
|
+
if (typeof global.tizen !== 'undefined' || typeof global.webOS !== 'undefined' || typeof window.qt !== 'undefined') {
|
|
3
3
|
return Promise.resolve(false);
|
|
4
4
|
}
|
|
5
5
|
return Promise.resolve(true);
|