@stremio/stremio-video 0.0.39 → 0.0.41

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.39",
3
+ "version": "0.0.41",
4
4
  "description": "Abstraction layer on top of different media players",
5
5
  "author": "Smart Code OOD",
6
6
  "main": "src/index.js",
@@ -106,21 +106,15 @@ var stremioColors = {
106
106
  };
107
107
 
108
108
  function stremioSubOffsets(offset) {
109
- if (offset === 0) {
109
+ if (offset <= 0) {
110
110
  return -3;
111
- } else if (offset <= 2) {
112
- return -2;
113
- } else if (offset <= 3) {
114
- return -1;
115
111
  } else if (offset <= 5) {
116
- return 0;
112
+ return -2;
117
113
  } else if (offset <= 10) {
118
- return 1;
119
- } else if (offset <= 25) {
114
+ return 0;
115
+ } else if (offset <= 15) {
120
116
  return 2;
121
- } else if (offset <= 50) {
122
- return 3;
123
- } else if (offset <= 100) {
117
+ } else if (offset <= 20) {
124
118
  return 4;
125
119
  }
126
120
  return false;
@@ -128,14 +122,14 @@ function stremioSubOffsets(offset) {
128
122
 
129
123
  function stremioSubSizes(size) {
130
124
  // there is also: 0 (tiny)
131
- // adding zero will break the logic
132
- if (size <= 75) {
125
+ if (size <= 100) {
133
126
  return 1;
134
- } else if (size <= 100) {
127
+ } else if (size <= 125) {
128
+ // not used because of 50% step
135
129
  return 2;
136
130
  } else if (size <= 150) {
137
131
  return 3;
138
- } else if (size <= 250) {
132
+ } else if (size <= 200) {
139
133
  return 4;
140
134
  }
141
135
  return false;
@@ -150,6 +144,8 @@ function WebOsVideo(options) {
150
144
  throw new Error('Container element required to be instance of HTMLElement');
151
145
  }
152
146
 
147
+ var isLoaded = false;
148
+
153
149
  var knownMediaId = false;
154
150
 
155
151
  var subSize = 75;
@@ -183,7 +179,7 @@ function WebOsVideo(options) {
183
179
  for (var i = 0; i < info.subtitleTrackInfo.length; i++) {
184
180
  var textTrack = info.subtitleTrackInfo[i];
185
181
  textTrack.index = i;
186
- var textTrackLang = textTrack.language === '(null)' ? '' : textTrack.language;
182
+ var textTrackLang = textTrack.language === '(null)' ? null : textTrack.language;
187
183
 
188
184
  var textTrackId = 'EMBEDDED_' + textTrack.index;
189
185
 
@@ -217,7 +213,7 @@ function WebOsVideo(options) {
217
213
  if (!currentAudioTrack && !audioTracks.length) {
218
214
  currentAudioTrack = audioTrackId;
219
215
  }
220
- var audioTrackLang = audioTrack.language === '(null)' ? '' : audioTrack.language;
216
+ var audioTrackLang = audioTrack.language === '(null)' ? null : audioTrack.language;
221
217
  audioTracks.push({
222
218
  id: audioTrackId,
223
219
  lang: audioTrackLang,
@@ -372,6 +368,10 @@ function WebOsVideo(options) {
372
368
  videoElement.onplaying = function() {
373
369
  onPropChanged('buffering');
374
370
  onPropChanged('buffered');
371
+ if (!isLoaded) {
372
+ isLoaded = true;
373
+ onPropChanged('loaded');
374
+ }
375
375
  };
376
376
  videoElement.oncanplay = function() {
377
377
  onPropChanged('buffering');
@@ -419,6 +419,7 @@ function WebOsVideo(options) {
419
419
  var subtitlesOpacity = 100;
420
420
  var observedProps = {
421
421
  stream: false,
422
+ loaded: false,
422
423
  paused: false,
423
424
  time: false,
424
425
  duration: false,
@@ -443,6 +444,9 @@ function WebOsVideo(options) {
443
444
  case 'stream': {
444
445
  return stream;
445
446
  }
447
+ case 'loaded': {
448
+ return isLoaded;
449
+ }
446
450
  case 'paused': {
447
451
  if (stream === null) {
448
452
  return null;
@@ -742,7 +746,7 @@ function WebOsVideo(options) {
742
746
  subtitlesOffset = propValue;
743
747
  var nextOffset = stremioSubOffsets(Math.max(0, Math.min(100, parseInt(subtitlesOffset, 10))));
744
748
  if (nextOffset === false) { // use default
745
- nextOffset = -1;
749
+ nextOffset = -2;
746
750
  }
747
751
  subStyles.position = nextOffset;
748
752
  if (videoElement.mediaId) {
@@ -951,6 +955,7 @@ function WebOsVideo(options) {
951
955
  onPropChanged('stream');
952
956
  videoElement.autoplay = typeof commandArgs.autoplay === 'boolean' ? commandArgs.autoplay : true;
953
957
 
958
+ onPropChanged('loaded');
954
959
  onPropChanged('paused');
955
960
  onPropChanged('time');
956
961
  onPropChanged('duration');
@@ -1120,7 +1125,7 @@ WebOsVideo.canPlayStream = function() { // function(stream)
1120
1125
  WebOsVideo.manifest = {
1121
1126
  name: 'WebOsVideo',
1122
1127
  external: false,
1123
- props: ['stream', 'paused', 'time', 'duration', 'buffering', 'buffered', 'audioTracks', 'selectedAudioTrackId', 'subtitlesTracks', 'selectedSubtitlesTrackId', 'subtitlesOffset', 'subtitlesSize', 'subtitlesTextColor', 'subtitlesBackgroundColor', 'subtitlesOpacity', 'volume', 'muted', 'playbackSpeed'],
1128
+ props: ['stream', 'loaded', 'paused', 'time', 'duration', 'buffering', 'buffered', 'audioTracks', 'selectedAudioTrackId', 'subtitlesTracks', 'selectedSubtitlesTrackId', 'subtitlesOffset', 'subtitlesSize', 'subtitlesTextColor', 'subtitlesBackgroundColor', 'subtitlesOpacity', 'volume', 'muted', 'playbackSpeed'],
1124
1129
  commands: ['load', 'unload', 'destroy'],
1125
1130
  events: ['propValue', 'propChanged', 'ended', 'error', 'subtitlesTrackLoaded', 'audioTrackLoaded']
1126
1131
  };