@stremio/stremio-video 0.0.75 → 0.0.77

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.75",
3
+ "version": "0.0.77",
4
4
  "description": "Abstraction layer on top of different media players",
5
5
  "author": "Smart Code OOD",
6
6
  "main": "src/index.js",
@@ -22,6 +22,7 @@ function HTMLVideo(options) {
22
22
  videoElement.style.width = '100%';
23
23
  videoElement.style.height = '100%';
24
24
  videoElement.style.backgroundColor = 'black';
25
+ videoElement.style.objectFit = 'contain';
25
26
  videoElement.controls = false;
26
27
  videoElement.playsInline = true;
27
28
  videoElement.onerror = function() {
@@ -123,7 +124,8 @@ function HTMLVideo(options) {
123
124
  selectedAudioTrackId: false,
124
125
  volume: false,
125
126
  muted: false,
126
- playbackSpeed: false
127
+ playbackSpeed: false,
128
+ videoScale: false
127
129
  };
128
130
 
129
131
  function getProp(propName) {
@@ -308,6 +310,9 @@ function HTMLVideo(options) {
308
310
 
309
311
  return videoElement.playbackRate;
310
312
  }
313
+ case 'videoScale': {
314
+ return videoElement.style.objectFit || 'contain';
315
+ }
311
316
  default: {
312
317
  return null;
313
318
  }
@@ -520,6 +525,15 @@ function HTMLVideo(options) {
520
525
  onPropChanged('playbackSpeed');
521
526
  }
522
527
 
528
+ break;
529
+ }
530
+ case 'videoScale': {
531
+ var validValues = ['contain', 'cover', 'fill'];
532
+ if (validValues.indexOf(propValue) !== -1) {
533
+ videoElement.style.objectFit = propValue;
534
+ onPropChanged('videoScale');
535
+ }
536
+
523
537
  break;
524
538
  }
525
539
  }
@@ -696,7 +710,7 @@ HTMLVideo.canPlayStream = function(stream) {
696
710
  HTMLVideo.manifest = {
697
711
  name: 'HTMLVideo',
698
712
  external: false,
699
- props: ['stream', 'loaded', 'paused', 'time', 'duration', 'buffering', 'buffered', 'audioTracks', 'selectedAudioTrackId', 'subtitlesTracks', 'selectedSubtitlesTrackId', 'subtitlesOffset', 'subtitlesSize', 'subtitlesTextColor', 'subtitlesBackgroundColor', 'subtitlesOutlineColor', 'subtitlesOpacity', 'volume', 'muted', 'playbackSpeed'],
713
+ props: ['stream', 'loaded', 'paused', 'time', 'duration', 'buffering', 'buffered', 'audioTracks', 'selectedAudioTrackId', 'subtitlesTracks', 'selectedSubtitlesTrackId', 'subtitlesOffset', 'subtitlesSize', 'subtitlesTextColor', 'subtitlesBackgroundColor', 'subtitlesOutlineColor', 'subtitlesOpacity', 'volume', 'muted', 'playbackSpeed', 'videoScale'],
700
714
  commands: ['load', 'unload', 'destroy'],
701
715
  events: ['propValue', 'propChanged', 'ended', 'error', 'subtitlesTrackLoaded', 'audioTrackLoaded']
702
716
  };
@@ -26,6 +26,8 @@ var stremioToMPVProps = {
26
26
  'subtitlesTextColor': 'sub-color',
27
27
  'subtitlesBackgroundColor': 'sub-back-color',
28
28
  'subtitlesOutlineColor': 'sub-border-color',
29
+ 'hdrInfo': null,
30
+ 'videoScale': null,
29
31
  };
30
32
 
31
33
  function parseVersion(version) {
@@ -191,6 +193,23 @@ function ShellVideo(options) {
191
193
  props[args.name] = embeddedProp(args);
192
194
  break;
193
195
  }
196
+ case 'video-params': {
197
+ props[args.name] = args.data;
198
+ var params = args.data || {};
199
+ var gamma = typeof params.gamma === 'string' ? params.gamma : null;
200
+ if (gamma === 'pq' || gamma === 'hlg') {
201
+ props.hdrInfo = {
202
+ gamma: gamma,
203
+ primaries: typeof params.primaries === 'string' ? params.primaries : null,
204
+ maxCll: typeof params['max-cll'] === 'number' ? params['max-cll'] : null,
205
+ maxLuma: typeof params['max-luma'] === 'number' ? params['max-luma'] : null,
206
+ };
207
+ } else {
208
+ props.hdrInfo = null;
209
+ }
210
+ onPropChanged('hdrInfo');
211
+ break;
212
+ }
194
213
  // In that case onPropChanged() is manually invoked as track-list contains all
195
214
  // the tracks but we have different event for each track type
196
215
  case 'track-list': {
@@ -243,6 +262,8 @@ function ShellVideo(options) {
243
262
  });
244
263
 
245
264
  function getProp(propName) {
265
+ if (propName === 'hdrInfo') return props.hdrInfo || null;
266
+ if (propName === 'videoScale') return props.videoScale || 'contain';
246
267
  if(stremioToMPVProps[propName]) return props[stremioToMPVProps[propName]];
247
268
  // eslint-disable-next-line no-console
248
269
  console.log('Unsupported prop requested', propName);
@@ -288,6 +309,27 @@ function ShellVideo(options) {
288
309
  }
289
310
  break;
290
311
  }
312
+ case 'videoScale': {
313
+ if (stream !== null) {
314
+ switch (propValue) {
315
+ case 'cover':
316
+ ipc.send('mpv-set-prop', ['keepaspect', true]);
317
+ ipc.send('mpv-set-prop', ['panscan', 1.0]);
318
+ break;
319
+ case 'fill':
320
+ ipc.send('mpv-set-prop', ['keepaspect', false]);
321
+ ipc.send('mpv-set-prop', ['panscan', 0.0]);
322
+ break;
323
+ default:
324
+ ipc.send('mpv-set-prop', ['keepaspect', true]);
325
+ ipc.send('mpv-set-prop', ['panscan', 0.0]);
326
+ break;
327
+ }
328
+ props.videoScale = propValue;
329
+ onPropChanged('videoScale');
330
+ }
331
+ break;
332
+ }
291
333
  case 'volume': {
292
334
  if (stream !== null && propValue !== null && isFinite(propValue)) {
293
335
  props.mute = false;
@@ -371,9 +413,14 @@ function ShellVideo(options) {
371
413
  var hwdecValue = commandArgs.hardwareDecoding ? 'auto-copy' : 'no';
372
414
  ipc.send('mpv-set-prop', ['hwdec', hwdecValue]);
373
415
 
374
- // Video mode
375
- var videoOutput = commandArgs.platform === 'windows' ? (commandArgs.videoMode === null ? 'gpu-next' : 'gpu') : 'libmpv';
376
- ipc.send('mpv-set-prop', ['vo', videoOutput]);
416
+ // On macOS the shell manages vo and HDR/EDR configuration
417
+ // directly do not override vo here.
418
+ var platformLower = String(commandArgs.platform || '').toLowerCase();
419
+ var isMac = platformLower.indexOf('mac') !== -1;
420
+ if (!isMac) {
421
+ var videoOutput = platformLower === 'windows' ? (commandArgs.videoMode === null ? 'gpu-next' : 'gpu') : 'libmpv';
422
+ ipc.send('mpv-set-prop', ['vo', videoOutput]);
423
+ }
377
424
 
378
425
  var separateWindow = options.mpvSeparateWindow ? 'yes' : 'no';
379
426
  ipc.send('mpv-set-prop', ['osc', separateWindow]);