@scarlett-player/native 1.12.0 → 1.14.0

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/dist/index.cjs CHANGED
@@ -27,7 +27,7 @@ module.exports = __toCommonJS(index_exports);
27
27
  var import_core = require("@scarlett-player/core");
28
28
 
29
29
  // src/version.ts
30
- var PKG_VERSION = true ? "1.12.0" : "0.0.0-dev";
30
+ var PKG_VERSION = true ? "1.13.0" : "0.0.0-dev";
31
31
 
32
32
  // src/index.ts
33
33
  var VIDEO_EXTENSIONS = ["mp4", "webm", "mov", "mkv", "ogv", "m4v"];
@@ -66,6 +66,7 @@ function createNativePlugin(config) {
66
66
  let derived_title = null;
67
67
  let is_audio_source = false;
68
68
  let isCorePlayRequested = false;
69
+ let isCorePauseRequested = false;
69
70
  let loadSession = 0;
70
71
  let abortPendingLoad = null;
71
72
  let has_parsed_source = false;
@@ -158,6 +159,7 @@ function createNativePlugin(config) {
158
159
  api?.setState("paused", false);
159
160
  api?.setState("playbackState", "playing");
160
161
  syncEndedFromElement();
162
+ isCorePauseRequested = false;
161
163
  if (isCorePlayRequested) {
162
164
  isCorePlayRequested = false;
163
165
  } else {
@@ -169,6 +171,11 @@ function createNativePlugin(config) {
169
171
  api?.setState("playing", false);
170
172
  api?.setState("paused", true);
171
173
  api?.setState("playbackState", "paused");
174
+ if (isCorePauseRequested) {
175
+ isCorePauseRequested = false;
176
+ } else {
177
+ api?.emit("playback:pause", void 0);
178
+ }
172
179
  });
173
180
  on("ended", () => {
174
181
  api?.setState("playing", false);
@@ -279,6 +286,8 @@ function createNativePlugin(config) {
279
286
  const cleanup = () => {
280
287
  cleanupEvents?.();
281
288
  cleanupEvents = null;
289
+ isCorePlayRequested = false;
290
+ isCorePauseRequested = false;
282
291
  if (video) {
283
292
  video.pause();
284
293
  video.removeAttribute("src");
@@ -316,8 +325,17 @@ function createNativePlugin(config) {
316
325
  });
317
326
  const unsubPause = api.on("playback:pause", () => {
318
327
  if (api?.getState("chromecastActive")) return;
328
+ if (!video) return;
329
+ if (video.paused) {
330
+ if (isCorePlayRequested) {
331
+ isCorePlayRequested = false;
332
+ video.pause();
333
+ }
334
+ return;
335
+ }
336
+ isCorePauseRequested = true;
319
337
  isCorePlayRequested = false;
320
- video?.pause();
338
+ video.pause();
321
339
  });
322
340
  const unsubSeek = api.on("playback:seeking", ({ time }) => {
323
341
  if (api?.getState("chromecastActive")) return;
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { ErrorCode, sanitizeUrl } from "@scarlett-player/core";
3
3
 
4
4
  // src/version.ts
5
- var PKG_VERSION = true ? "1.12.0" : "0.0.0-dev";
5
+ var PKG_VERSION = true ? "1.13.0" : "0.0.0-dev";
6
6
 
7
7
  // src/index.ts
8
8
  var VIDEO_EXTENSIONS = ["mp4", "webm", "mov", "mkv", "ogv", "m4v"];
@@ -41,6 +41,7 @@ function createNativePlugin(config) {
41
41
  let derived_title = null;
42
42
  let is_audio_source = false;
43
43
  let isCorePlayRequested = false;
44
+ let isCorePauseRequested = false;
44
45
  let loadSession = 0;
45
46
  let abortPendingLoad = null;
46
47
  let has_parsed_source = false;
@@ -133,6 +134,7 @@ function createNativePlugin(config) {
133
134
  api?.setState("paused", false);
134
135
  api?.setState("playbackState", "playing");
135
136
  syncEndedFromElement();
137
+ isCorePauseRequested = false;
136
138
  if (isCorePlayRequested) {
137
139
  isCorePlayRequested = false;
138
140
  } else {
@@ -144,6 +146,11 @@ function createNativePlugin(config) {
144
146
  api?.setState("playing", false);
145
147
  api?.setState("paused", true);
146
148
  api?.setState("playbackState", "paused");
149
+ if (isCorePauseRequested) {
150
+ isCorePauseRequested = false;
151
+ } else {
152
+ api?.emit("playback:pause", void 0);
153
+ }
147
154
  });
148
155
  on("ended", () => {
149
156
  api?.setState("playing", false);
@@ -254,6 +261,8 @@ function createNativePlugin(config) {
254
261
  const cleanup = () => {
255
262
  cleanupEvents?.();
256
263
  cleanupEvents = null;
264
+ isCorePlayRequested = false;
265
+ isCorePauseRequested = false;
257
266
  if (video) {
258
267
  video.pause();
259
268
  video.removeAttribute("src");
@@ -291,8 +300,17 @@ function createNativePlugin(config) {
291
300
  });
292
301
  const unsubPause = api.on("playback:pause", () => {
293
302
  if (api?.getState("chromecastActive")) return;
303
+ if (!video) return;
304
+ if (video.paused) {
305
+ if (isCorePlayRequested) {
306
+ isCorePlayRequested = false;
307
+ video.pause();
308
+ }
309
+ return;
310
+ }
311
+ isCorePauseRequested = true;
294
312
  isCorePlayRequested = false;
295
- video?.pause();
313
+ video.pause();
296
314
  });
297
315
  const unsubSeek = api.on("playback:seeking", ({ time }) => {
298
316
  if (api?.getState("chromecastActive")) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scarlett-player/native",
3
- "version": "1.12.0",
3
+ "version": "1.14.0",
4
4
  "description": "Native Video Provider Plugin for Scarlett Player (MP4, WebM, MOV, MKV)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -24,7 +24,7 @@
24
24
  "tsup": "^8.0.0",
25
25
  "vitest": "^1.6.0",
26
26
  "jsdom": "^24.0.0",
27
- "@scarlett-player/core": "1.12.0"
27
+ "@scarlett-player/core": "1.14.0"
28
28
  },
29
29
  "keywords": [
30
30
  "video",