@stremio/stremio-video 0.0.35 → 0.0.39-beta.3

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.35",
3
+ "version": "0.0.39-beta.3",
4
4
  "description": "Abstraction layer on top of different media players",
5
5
  "author": "Smart Code OOD",
6
6
  "main": "src/index.js",
@@ -11,5 +11,21 @@ module.exports = {
11
11
  nudgeMaxRetry: 20,
12
12
  manifestLoadingTimeOut: 30000,
13
13
  manifestLoadingMaxRetry: 10,
14
+ fragLoadPolicy: {
15
+ default: {
16
+ maxTimeToFirstByteMs: 10000,
17
+ maxLoadTimeMs: 120000,
18
+ timeoutRetry: {
19
+ maxNumRetry: 20,
20
+ retryDelayMs: 0,
21
+ maxRetryDelayMs: 15
22
+ },
23
+ errorRetry: {
24
+ maxNumRetry: 6,
25
+ retryDelayMs: 1000,
26
+ maxRetryDelayMs: 15
27
+ }
28
+ }
29
+ }
14
30
  // liveDurationInfinity: false
15
31
  };
@@ -671,6 +671,7 @@ function WebOsVideo(options) {
671
671
  if (stream !== null && videoElement.readyState >= videoElement.HAVE_METADATA && propValue !== null && isFinite(propValue)) {
672
672
  try {
673
673
  videoElement.currentTime = parseInt(propValue, 10) / 1000;
674
+ onPropChanged('time');
674
675
  } catch(e) {
675
676
  // console.log('webos video change time error');
676
677
  // console.error(e);
@@ -0,0 +1,8 @@
1
+ function supportsTranscoding() {
2
+ if (typeof global.tizen !== 'undefined' || typeof global.webOS !== 'undefined') {
3
+ return Promise.resolve(false);
4
+ }
5
+ return Promise.resolve(true);
6
+ }
7
+
8
+ module.exports = supportsTranscoding;
@@ -0,0 +1,7 @@
1
+ var url = require('url');
2
+
3
+ function destroyHLSConverter(streamingServerURL, id) {
4
+ return fetch(url.resolve(streamingServerURL, '/hlsv2/' + encodeURIComponent(id) + '/destroy'));
5
+ }
6
+
7
+ module.exports = destroyHLSConverter;
@@ -6,6 +6,8 @@ var deepFreeze = require('deep-freeze');
6
6
  var mediaCapabilities = require('../mediaCapabilities');
7
7
  var convertStream = require('./convertStream');
8
8
  var fetchVideoParams = require('./fetchVideoParams');
9
+ var destroyHLSConverter = require('./destroyHLSConverter');
10
+ var supportsTranscoding = require('../supportsTranscoding');
9
11
  var ERROR = require('../error');
10
12
 
11
13
  function withStreamingServer(Video) {
@@ -26,6 +28,7 @@ function withStreamingServer(Video) {
26
28
 
27
29
  var self = this;
28
30
  var loadArgs = null;
31
+ var hlsConverterId = null;
29
32
  var loaded = false;
30
33
  var actionsQueue = [];
31
34
  var videoParams = null;
@@ -140,6 +143,7 @@ function withStreamingServer(Video) {
140
143
  mediaURL: mediaURL,
141
144
  infoHash: infoHash,
142
145
  fileIdx: fileIdx,
146
+ hlsConverterId: null,
143
147
  stream: {
144
148
  url: mediaURL
145
149
  }
@@ -166,6 +170,7 @@ function withStreamingServer(Video) {
166
170
  mediaURL: mediaURL,
167
171
  infoHash: infoHash,
168
172
  fileIdx: fileIdx,
173
+ hlsConverterId: id,
169
174
  stream: {
170
175
  url: url.resolve(commandArgs.streamingServerURL, '/hlsv2/' + id + '/master.m3u8?' + queryParams.toString()),
171
176
  subtitles: Array.isArray(commandArgs.stream.subtitles) ?
@@ -200,6 +205,7 @@ function withStreamingServer(Video) {
200
205
  stream: result.stream
201
206
  })
202
207
  });
208
+ hlsConverterId = result.hlsConverterId;
203
209
  loaded = true;
204
210
  flushActionsQueue();
205
211
  fetchVideoParams(commandArgs.streamingServerURL, result.mediaURL, result.infoHash, result.fileIdx, commandArgs.stream.behaviorHints)
@@ -273,6 +279,13 @@ function withStreamingServer(Video) {
273
279
  return true;
274
280
  }
275
281
  case 'unload': {
282
+ if (loadArgs && hlsConverterId !== null) {
283
+ destroyHLSConverter(loadArgs.streamingServerURL, hlsConverterId).catch(function(error) {
284
+ // eslint-disable-next-line no-console
285
+ console.error(error);
286
+ });
287
+ }
288
+ hlsConverterId = null;
276
289
  loadArgs = null;
277
290
  loaded = false;
278
291
  actionsQueue = [];
@@ -341,15 +354,13 @@ function withStreamingServer(Video) {
341
354
  }
342
355
 
343
356
  VideoWithStreamingServer.canPlayStream = function(stream, options) {
344
- return Video.canPlayStream(stream)
345
- .then(function(canPlay) {
346
- if (!canPlay) {
347
- throw new Error('Fallback using /hlsv2/probe');
357
+ return supportsTranscoding()
358
+ .then(function(supported) {
359
+ if (!supported) {
360
+ // we cannot probe the video in this case
361
+ return Video.canPlayStream(stream);
348
362
  }
349
-
350
- return canPlay;
351
- })
352
- .catch(function() {
363
+ // probing normally gives more accurate results
353
364
  var queryParams = new URLSearchParams([['mediaURL', stream.url]]);
354
365
  return fetch(url.resolve(options.streamingServerURL, '/hlsv2/probe?' + queryParams.toString()))
355
366
  .then(function(resp) {
@@ -370,6 +381,11 @@ function withStreamingServer(Video) {
370
381
  return true;
371
382
  });
372
383
  return isFormatSupported && areStreamsSupported;
384
+ })
385
+ .catch(function() {
386
+ // this uses content-type header in HTMLVideo which
387
+ // is unreliable, check can also fail due to CORS
388
+ return Video.canPlayStream(stream);
373
389
  });
374
390
  });
375
391
  };