@stremio/stremio-video 0.0.74 → 0.0.75

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.74",
3
+ "version": "0.0.75",
4
4
  "description": "Abstraction layer on top of different media players",
5
5
  "author": "Smart Code OOD",
6
6
  "main": "src/index.js",
@@ -43,6 +43,7 @@ function withHTMLSubtitles(Video) {
43
43
  var videoState = {
44
44
  time: null,
45
45
  paused: false,
46
+ buffering: false,
46
47
  lastSyncAt: null,
47
48
  playbackSpeed: 1
48
49
  };
@@ -78,7 +79,7 @@ function withHTMLSubtitles(Video) {
78
79
  if (videoState.time === null || !isFinite(videoState.time)) {
79
80
  return null;
80
81
  }
81
- if (videoState.paused || videoState.lastSyncAt === null) {
82
+ if (videoState.paused || videoState.buffering || videoState.lastSyncAt === null) {
82
83
  return videoState.time;
83
84
  }
84
85
  return videoState.time + (Date.now() - videoState.lastSyncAt) * videoState.playbackSpeed;
@@ -156,7 +157,7 @@ function withHTMLSubtitles(Video) {
156
157
  break;
157
158
  }
158
159
  case 'paused': {
159
- if (propValue && !videoState.paused && videoState.lastSyncAt !== null && videoState.time !== null) {
160
+ if (propValue && !videoState.paused && !videoState.buffering && videoState.lastSyncAt !== null && videoState.time !== null) {
160
161
  videoState.time = videoState.time + (Date.now() - videoState.lastSyncAt) * videoState.playbackSpeed;
161
162
  videoState.lastSyncAt = Date.now();
162
163
  } else if (!propValue && videoState.paused) {
@@ -165,9 +166,19 @@ function withHTMLSubtitles(Video) {
165
166
  videoState.paused = propValue;
166
167
  break;
167
168
  }
169
+ case 'buffering': {
170
+ if (propValue && !videoState.buffering && !videoState.paused && videoState.lastSyncAt !== null && videoState.time !== null) {
171
+ videoState.time = videoState.time + (Date.now() - videoState.lastSyncAt) * videoState.playbackSpeed;
172
+ videoState.lastSyncAt = Date.now();
173
+ } else if (!propValue && videoState.buffering) {
174
+ videoState.lastSyncAt = Date.now();
175
+ }
176
+ videoState.buffering = propValue;
177
+ break;
178
+ }
168
179
  case 'playbackSpeed': {
169
180
  if (propValue !== null && isFinite(propValue)) {
170
- if (!videoState.paused && videoState.lastSyncAt !== null && videoState.time !== null) {
181
+ if (!videoState.paused && !videoState.buffering && videoState.lastSyncAt !== null && videoState.time !== null) {
171
182
  videoState.time = videoState.time + (Date.now() - videoState.lastSyncAt) * videoState.playbackSpeed;
172
183
  videoState.lastSyncAt = Date.now();
173
184
  }
@@ -289,6 +300,9 @@ function withHTMLSubtitles(Video) {
289
300
  function setProp(propName, propValue) {
290
301
  switch (propName) {
291
302
  case 'selectedExtraSubtitlesTrackId': {
303
+ if (propValue !== null && selectedTrackId === propValue) {
304
+ return true;
305
+ }
292
306
  cuesByTime = null;
293
307
  selectedTrackId = null;
294
308
  delay = null;