@stremio/stremio-video 0.0.76 → 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.76",
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
  };
@@ -27,6 +27,7 @@ var stremioToMPVProps = {
27
27
  'subtitlesBackgroundColor': 'sub-back-color',
28
28
  'subtitlesOutlineColor': 'sub-border-color',
29
29
  'hdrInfo': null,
30
+ 'videoScale': null,
30
31
  };
31
32
 
32
33
  function parseVersion(version) {
@@ -262,6 +263,7 @@ function ShellVideo(options) {
262
263
 
263
264
  function getProp(propName) {
264
265
  if (propName === 'hdrInfo') return props.hdrInfo || null;
266
+ if (propName === 'videoScale') return props.videoScale || 'contain';
265
267
  if(stremioToMPVProps[propName]) return props[stremioToMPVProps[propName]];
266
268
  // eslint-disable-next-line no-console
267
269
  console.log('Unsupported prop requested', propName);
@@ -307,6 +309,27 @@ function ShellVideo(options) {
307
309
  }
308
310
  break;
309
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
+ }
310
333
  case 'volume': {
311
334
  if (stream !== null && propValue !== null && isFinite(propValue)) {
312
335
  props.mute = false;