@stremio/stremio-video 0.0.62 → 0.0.64

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.62",
3
+ "version": "0.0.64",
4
4
  "description": "Abstraction layer on top of different media players",
5
5
  "author": "Smart Code OOD",
6
6
  "main": "src/index.js",
@@ -362,13 +362,11 @@ function ShellVideo(options) {
362
362
  var hwdecValue = commandArgs.hardwareDecoding ? 'auto-copy' : 'no';
363
363
  ipc.send('mpv-set-prop', ['hwdec', hwdecValue]);
364
364
 
365
- // opengl-cb is an alias for the new name "libmpv", as shown in mpv's video/out/vo.c aliases
366
- // opengl is an alias for the new name "gpu"
367
- // When on Windows we use d3d for the rendering in separate window
368
- var windowRenderer = navigator.platform === 'Win32' ? 'direct3d' : 'opengl';
369
- var videoOutput = options.mpvSeparateWindow ? windowRenderer : 'opengl-cb';
370
- var separateWindow = options.mpvSeparateWindow ? 'yes' : 'no';
365
+ // Video mode
366
+ var videoOutput = commandArgs.platform === 'windows' ? (commandArgs.videoMode === null ? 'gpu-next' : 'gpu') : 'libmpv';
371
367
  ipc.send('mpv-set-prop', ['vo', videoOutput]);
368
+
369
+ var separateWindow = options.mpvSeparateWindow ? 'yes' : 'no';
372
370
  ipc.send('mpv-set-prop', ['osc', separateWindow]);
373
371
  ipc.send('mpv-set-prop', ['input-default-bindings', separateWindow]);
374
372
  ipc.send('mpv-set-prop', ['input-vo-keyboard', separateWindow]);
@@ -4,7 +4,6 @@ var deepFreeze = require('deep-freeze');
4
4
  var Color = require('color');
5
5
  var ERROR = require('../error');
6
6
  var getTracksData = require('../tracksData');
7
- var createAVPlay = require('./AVPlay');
8
7
 
9
8
  var SSA_DESCRIPTORS_REGEX = /^\{(\\an[1-8])+\}/i;
10
9
 
@@ -21,7 +20,7 @@ function TizenVideo(options) {
21
20
  throw new Error('Container element required to be instance of HTMLElement');
22
21
  }
23
22
 
24
- var AVPlay = createAVPlay(options.transport);
23
+ var AVPlay = window.webapis.avplay;
25
24
 
26
25
  var promiseAudioTrackChange = false;
27
26
 
@@ -41,17 +40,17 @@ function TizenVideo(options) {
41
40
  var lastSub;
42
41
  var disabledSubs = false;
43
42
 
44
- async function refreshSubtitle() {
43
+ function refreshSubtitle() {
45
44
  if (lastSub) {
46
- var currentTime = await getProp('time');
45
+ var currentTime = getProp('time');
47
46
  var lastSubDurationDiff = lastSub.duration - (currentTime - lastSub.now);
48
47
  if (lastSubDurationDiff > 0) renderSubtitle(lastSubDurationDiff, lastSub.text);
49
48
  }
50
49
  }
51
50
 
52
- async function renderSubtitle(duration, text) {
51
+ function renderSubtitle(duration, text) {
53
52
  if (disabledSubs) return;
54
- var now = await getProp('time');
53
+ var now = getProp('time');
55
54
  var cleanedText = text.replace(SSA_DESCRIPTORS_REGEX, '');
56
55
 
57
56
  // we ignore custom delay here, it's not needed for embedded subs
@@ -178,7 +177,7 @@ function TizenVideo(options) {
178
177
  }
179
178
  }
180
179
 
181
- async function getProp(propName) {
180
+ function getProp(propName) {
182
181
  switch (propName) {
183
182
  case 'stream': {
184
183
  return stream;
@@ -191,7 +190,7 @@ function TizenVideo(options) {
191
190
  return null;
192
191
  }
193
192
 
194
- var state = await AVPlay.getState();
193
+ var state = AVPlay.getState();
195
194
  var isPaused = !!(state === 'PAUSED');
196
195
 
197
196
  if (!isPaused && promiseAudioTrackChange) {
@@ -202,7 +201,7 @@ function TizenVideo(options) {
202
201
  return isPaused;
203
202
  }
204
203
  case 'time': {
205
- var currentTime = await AVPlay.getCurrentTime();
204
+ var currentTime = AVPlay.getCurrentTime();
206
205
  if (stream === null || currentTime === null || !isFinite(currentTime)) {
207
206
  return null;
208
207
  }
@@ -210,7 +209,7 @@ function TizenVideo(options) {
210
209
  return Math.floor(currentTime);
211
210
  }
212
211
  case 'duration': {
213
- var duration = await AVPlay.getDuration();
212
+ var duration = AVPlay.getDuration();
214
213
  if (stream === null || duration === null || !isFinite(duration)) {
215
214
  return null;
216
215
  }
@@ -229,7 +228,7 @@ function TizenVideo(options) {
229
228
  return [];
230
229
  }
231
230
 
232
- var totalTrackInfo = await AVPlay.getTotalTrackInfo();
231
+ var totalTrackInfo = AVPlay.getTotalTrackInfo();
233
232
  var textTracks = [];
234
233
 
235
234
  for (var i = 0; i < totalTrackInfo.length; i++) {
@@ -272,7 +271,7 @@ function TizenVideo(options) {
272
271
  return null;
273
272
  }
274
273
 
275
- var currentTracks = await AVPlay.getCurrentStreamInfo();
274
+ var currentTracks = AVPlay.getCurrentStreamInfo();
276
275
  var currentIndex;
277
276
 
278
277
  for (var i = 0; i < currentTracks.length; i++) {
@@ -333,7 +332,7 @@ function TizenVideo(options) {
333
332
  return [];
334
333
  }
335
334
 
336
- var totalTrackInfo = await AVPlay.getTotalTrackInfo();
335
+ var totalTrackInfo = AVPlay.getTotalTrackInfo();
337
336
  var audioTracks = [];
338
337
 
339
338
  for (var i = 0; i < totalTrackInfo.length; i++) {
@@ -380,7 +379,7 @@ function TizenVideo(options) {
380
379
  return promiseAudioTrackChange;
381
380
  }
382
381
 
383
- var currentTracks = await AVPlay.getCurrentStreamInfo();
382
+ var currentTracks = AVPlay.getCurrentStreamInfo();
384
383
  var currentIndex = false;
385
384
 
386
385
  for (var i = 0; i < currentTracks.length; i++) {
@@ -414,20 +413,20 @@ function TizenVideo(options) {
414
413
  function onEnded() {
415
414
  events.emit('ended');
416
415
  }
417
- async function onPropChanged(propName) {
416
+ function onPropChanged(propName) {
418
417
  if (observedProps[propName]) {
419
- var propValue = await getProp(propName);
418
+ var propValue = getProp(propName);
420
419
  events.emit('propChanged', propName, propValue);
421
420
  }
422
421
  }
423
- async function observeProp(propName) {
422
+ function observeProp(propName) {
424
423
  if (observedProps.hasOwnProperty(propName)) {
425
- var propValue = await getProp(propName);
424
+ var propValue = getProp(propName);
426
425
  events.emit('propValue', propName, propValue);
427
426
  observedProps[propName] = true;
428
427
  }
429
428
  }
430
- async function setProp(propName, propValue) {
429
+ function setProp(propName, propValue) {
431
430
  switch (propName) {
432
431
  case 'paused': {
433
432
  if (stream !== null) {
@@ -446,10 +445,10 @@ function TizenVideo(options) {
446
445
 
447
446
  // the paused state is usually correct, but i have seen it not change on tizen 3
448
447
  // which causes all kinds of issues in the UI: (only happens with some videos)
449
- var lastKnownProp = await getProp('paused');
448
+ var lastKnownProp = getProp('paused');
450
449
 
451
- setTimeout(async function() {
452
- if (await getProp('paused') !== lastKnownProp) {
450
+ setTimeout(function() {
451
+ if (getProp('paused') !== lastKnownProp) {
453
452
  onPropChanged('paused');
454
453
  }
455
454
  }, 1000);
@@ -478,7 +477,7 @@ function TizenVideo(options) {
478
477
 
479
478
  currentSubTrack = propValue;
480
479
 
481
- var subtitlesTracks = await getProp('subtitlesTracks');
480
+ var subtitlesTracks = getProp('subtitlesTracks');
482
481
  var selectedSubtitlesTrack = subtitlesTracks
483
482
  .find(function(track) {
484
483
  return track.id === propValue;
@@ -584,13 +583,13 @@ function TizenVideo(options) {
584
583
  if (stream !== null) {
585
584
  currentAudioTrack = propValue;
586
585
 
587
- var audioTracks = await getProp('audioTracks');
586
+ var audioTracks = getProp('audioTracks');
588
587
  var selectedAudioTrack = audioTracks
589
588
  .find(function(track) {
590
589
  return track.id === propValue;
591
590
  });
592
591
 
593
- if (await getProp('paused')) {
592
+ if (getProp('paused')) {
594
593
  // issues before this logic:
595
594
  // tizen 3 does not allow changing audio track when paused
596
595
  // tizen 5 does, but it will only change getProp('selectedAudioTrackId') after playback starts
@@ -20,52 +20,6 @@ function luna(params, call, fail, method) {
20
20
  window.webOS.service.request(method || 'luna://com.webos.media', params);
21
21
  }
22
22
 
23
- function launchVideoApp(params, success, failure) {
24
- window.webOS.service.request('luna://com.webos.applicationManager', {
25
- method: 'launch',
26
- parameters: {
27
- 'id': params.id,
28
- 'params': {
29
- 'payload':[
30
- {
31
- 'fullPath': params.url,
32
- 'artist':'',
33
- 'subtitle':'',
34
- 'dlnaInfo':{
35
- 'flagVal':4096,
36
- 'cleartextSize':'-1',
37
- 'contentLength':'-1',
38
- 'opVal':1,
39
- 'protocolInfo':'http-get:*:video/x-matroska:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000',
40
- 'duration':0
41
- },
42
- 'mediaType':'VIDEO',
43
- 'thumbnail':'',
44
- 'deviceType':'DMR',
45
- 'album':'',
46
- 'fileName': params.name,
47
- 'lastPlayPosition': params.position
48
- }
49
- ]
50
- }
51
- },
52
- onSuccess: function () {
53
- success && success();
54
- },
55
- onFailure: function () {
56
- failure && failure(new Error('Failed to launch' + params.id));
57
-
58
- if (params.id === 'com.webos.app.photovideo') {
59
- params.id = 'com.webos.app.smartshare';
60
- launchVideoApp(params, success, failure);
61
- } else if(params.id === 'com.webos.app.smartshare') {
62
- params.id = 'com.webos.app.mediadiscovery';
63
- launchVideoApp(params, success, failure);
64
- }
65
- }
66
- });
67
- }
68
-
69
23
  var webOsColors = ['none', 'black', 'white', 'yellow', 'red', 'green', 'blue'];
70
24
  var stremioColors = {
71
25
  // rgba
@@ -562,28 +516,10 @@ function WebOsVideo(options) {
562
516
  }
563
517
  case 3: {
564
518
  error = ERROR.HTML_VIDEO.MEDIA_ERR_DECODE;
565
- launchVideoApp({
566
- id: 'com.webos.app.photovideo',
567
- url: stream.url,
568
- name: 'Stremio',
569
- position: -1,
570
- }, null, function(e) {
571
- // eslint-disable-next-line no-console
572
- console.error(e);
573
- });
574
519
  break;
575
520
  }
576
521
  case 4: {
577
522
  error = ERROR.HTML_VIDEO.MEDIA_ERR_SRC_NOT_SUPPORTED;
578
- launchVideoApp({
579
- id: 'com.webos.app.photovideo',
580
- url: stream.url,
581
- name: 'Stremio',
582
- position: -1,
583
- }, null, function(e) {
584
- // eslint-disable-next-line no-console
585
- console.error(e);
586
- });
587
523
  break;
588
524
  }
589
525
  default: {
@@ -1,98 +0,0 @@
1
- const SCOPE = 'AVPlay';
2
-
3
- const createAVPlay = (transport) => {
4
- const getState = () => {
5
- return transport.request(SCOPE, 'getState');
6
- };
7
-
8
- const getCurrentTime = () => {
9
- return transport.request(SCOPE, 'getCurrentTime');
10
- };
11
-
12
- const getDuration = () => {
13
- return transport.request(SCOPE, 'getDuration');
14
- };
15
-
16
- const getTotalTrackInfo = () => {
17
- return transport.request(SCOPE, 'getTotalTrackInfo');
18
- };
19
-
20
- const getCurrentStreamInfo = () => {
21
- return transport.request(SCOPE, 'getCurrentStreamInfo');
22
- };
23
-
24
- const open = (path) => {
25
- return transport.request(SCOPE, 'open', path);
26
- };
27
-
28
- const prepareAsync = async (successHandler, errorHandler) => {
29
- const [handler, handlerResult] = await transport.request(SCOPE, 'prepareAsync', 'handler:success', 'handler:error');
30
- if (handler === 'handler:success') successHandler();
31
- if (handler === 'handler:error') errorHandler(...handlerResult);
32
- };
33
-
34
- const pause = () => {
35
- return transport.request(SCOPE, 'pause');
36
- };
37
-
38
- const play = () => {
39
- return transport.request(SCOPE, 'play');
40
- };
41
-
42
- const stop = () => {
43
- return transport.request(SCOPE, 'stop');
44
- };
45
-
46
- const seekTo = (time) => {
47
- return transport.request(SCOPE, 'seekTo', time);
48
- };
49
-
50
- const setSpeed = (rate) => {
51
- return transport.request(SCOPE, 'setSpeed', rate);
52
- };
53
-
54
- const setSelectTrack = (type, id) => {
55
- return transport.request(SCOPE, 'setSelectTrack', type, id);
56
- };
57
-
58
- const setDisplayRect = (x, y, width, height) => {
59
- return transport.request(SCOPE, 'setDisplayRect', x, y, width, height);
60
- };
61
-
62
- const setDisplayMethod = (method) => {
63
- return transport.request(SCOPE, 'setDisplayMethod', method);
64
- };
65
-
66
- const setListener = (listener) => {
67
- const handlers = Object.keys(listener).map((name) => `handler:${name}`);
68
- const onHandlerResponse = (handler, handlerResult) => {
69
- const name = handler.replace('handler:', '');
70
- if (listener[name]) {
71
- handlerResult ? listener[name](...handlerResult) : listener[name]();
72
- }
73
- };
74
-
75
- transport.listen(SCOPE, 'setListener', onHandlerResponse, ...handlers);
76
- };
77
-
78
- return {
79
- getState,
80
- getCurrentTime,
81
- getDuration,
82
- getTotalTrackInfo,
83
- getCurrentStreamInfo,
84
- open,
85
- prepareAsync,
86
- pause,
87
- play,
88
- stop,
89
- seekTo,
90
- setSpeed,
91
- setSelectTrack,
92
- setDisplayRect,
93
- setDisplayMethod,
94
- setListener,
95
- };
96
- };
97
-
98
- module.exports = createAVPlay;