@vindral/web-sdk 4.5.1-5-g3596fa38 → 4.5.1-7-gaca7ab1e0

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.
@@ -8428,7 +8428,7 @@ function M_() {
8428
8428
  } catch (e) {
8429
8429
  throw o = "cached_edge", e;
8430
8430
  }
8431
- T(T_, e).call(e), E(p_, e, (a = T(p_, e), a++, a)), E(d_, e, 0), E(g_, e, performance.now()), T(x_, e).call(e), yield e.connectionImpl.closed(), e.logger.info("Connection closed"), o = "cached_edge";
8431
+ T(l_, e) || e.connectionImpl.close("Disconnected during connect"), T(T_, e).call(e), E(p_, e, (a = T(p_, e), a++, a)), E(d_, e, 0), E(g_, e, performance.now()), T(x_, e).call(e), yield e.connectionImpl.closed(), e.logger.info("Connection closed"), o = "cached_edge";
8432
8432
  } catch (n) {
8433
8433
  e.logger.warn("Failed to connect", n);
8434
8434
  let r = t.shiftedEdge();
@@ -11191,11 +11191,11 @@ var fy = class {
11191
11191
  if (!this.hasCalledConnect) {
11192
11192
  if (this.hasCalledConnect = !0, Object.values(this.modules).forEach((e) => {
11193
11193
  e && "load" in e && e.load();
11194
- }), this.unsuspend(), this.playbackSource instanceof Os) {
11194
+ }), this.playbackSource instanceof Os) {
11195
11195
  var e, t;
11196
11196
  (e = (t = this.playbackSource).load) == null || e.call(t);
11197
11197
  }
11198
- this.modules.connection.connect();
11198
+ this.unsuspend();
11199
11199
  }
11200
11200
  }), e(this, "getCastOptions", () => ({
11201
11201
  url: this.options.get("url"),
@@ -11452,7 +11452,7 @@ var fy = class {
11452
11452
  }), e(this, "pause", () => {
11453
11453
  if (this.options.get("pauseSupportEnabled") && (this.isUserPaused = !0, this.playbackState !== "paused" && this.playbackSource.pause(), this.hasCalledConnect)) {
11454
11454
  let e = !this.modules.documentState.isVisible;
11455
- this.suspend(e), e && this.disconnectForUserPausedInactivePage();
11455
+ this.suspend(e), e && this.disconnectForInactivePage("Background playback paused");
11456
11456
  }
11457
11457
  }), e(this, "registerDebugInstance", () => {
11458
11458
  Ds(this);
@@ -11471,8 +11471,8 @@ var fy = class {
11471
11471
  Object.values(this.modules).forEach((e) => {
11472
11472
  e && "reset" in e && e.reset();
11473
11473
  }), this.playbackSource instanceof Os && this.modules.adaptivity.reset(Ay), this.sampleProcessingSesssions.clear(), this.cleanupTextTracks(Infinity), this.playbackSource.currentTime = 0, this.playbackSource.isActivated = !1;
11474
- }), e(this, "disconnectForInactivePage", () => {
11475
- this.connectionState === "connected" && (this.modules.decoder || this.emitter.emit("flush buffers"), this.modules.connection.disconnect());
11474
+ }), e(this, "disconnectForInactivePage", (e) => {
11475
+ this.clearInactivityDisconnect(), this.emitter.emit("flush buffers"), this.connectionState !== "disconnected" && this.modules.connection.disconnect(e);
11476
11476
  }), e(this, "scheduleInactivityDisconnect", () => {
11477
11477
  this.clearInactivityDisconnect(), this.inactivityDisconnectInterval = this.modules.timer.setInterval(() => {
11478
11478
  let e = this.modules.pictureInPicture.isPictureInPictureActive(), t = this.playbackState === "paused" || this.muted && !e;
@@ -11480,9 +11480,7 @@ var fy = class {
11480
11480
  }, n.BACKGROUND_INACTIVITY_DISCONNECT_TIMEOUT);
11481
11481
  }), e(this, "clearInactivityDisconnect", () => {
11482
11482
  this.inactivityDisconnectInterval !== void 0 && (this.modules.timer.clearInterval(this.inactivityDisconnectInterval), this.inactivityDisconnectInterval = void 0);
11483
- }), e(this, "isHiddenWithBackgroundPlayback", () => !this.modules.documentState.isVisible && this.shouldAllowBackgroundPlayback(this.channelId)), e(this, "disconnectForUserPausedInactivePage", () => {
11484
- this.clearInactivityDisconnect(), this.emitter.emit("flush buffers"), this.connectionState === "connected" && this.modules.connection.disconnect("Background playback paused");
11485
- }), e(this, "resumeModules", () => {
11483
+ }), e(this, "isHiddenWithBackgroundPlayback", () => !this.modules.documentState.isVisible && this.shouldAllowBackgroundPlayback(this.channelId)), e(this, "isHiddenWithBackgroundPlayDisabled", () => !this.modules.documentState.isVisible && !this.isBackgroundPlayEnabled(this.channelId)), e(this, "resumeModules", () => {
11486
11484
  Object.values(this.modules).forEach((e) => {
11487
11485
  e && "unsuspend" in e && e.unsuspend();
11488
11486
  });
@@ -11490,7 +11488,7 @@ var fy = class {
11490
11488
  let e = this.modules.canvasModule instanceof Sv ? !0 : void 0;
11491
11489
  return O({
11492
11490
  uptime: this.uptime,
11493
- version: "4.5.1-5-g3596fa38",
11491
+ version: "4.5.1-7-gaca7ab1e0",
11494
11492
  clientId: this.clientId,
11495
11493
  sessionId: this.sessionId,
11496
11494
  channelId: this.channelId,
@@ -11512,7 +11510,11 @@ var fy = class {
11512
11510
  }), e(this, "onMediaElementBufferState", (e, t) => {
11513
11511
  this.emitter.emit("buffer state", this.getPlaybackBufferState(e, t));
11514
11512
  }), e(this, "onMediaElementState", (e) => {
11515
- this.logger.info("media element state", { state: e }), this.options.get("pauseSupportEnabled") && (e === "paused" ? this.modules.documentState.isVisible && (this.isUserPaused = !0, this.suspend(), this.modules.connection.disconnect()) : (this.isUserPaused = !1, this.unsuspend(), this.modules.connection.getState() === "disconnected" && this.modules.connection.unsuspend()));
11513
+ if (this.logger.info("media element state", { state: e }), this.options.get("pauseSupportEnabled")) if (e === "paused") this.modules.documentState.isVisible && (this.isUserPaused = !0, this.suspend(), this.modules.connection.disconnect());
11514
+ else {
11515
+ if (this.isUserPaused = !1, this.isHiddenWithBackgroundPlayDisabled()) return;
11516
+ this.unsuspend(), this.modules.connection.getState() === "disconnected" && this.modules.connection.unsuspend();
11517
+ }
11516
11518
  }), e(this, "onBufferEvent", (e) => {
11517
11519
  this.emit("buffer state event", e);
11518
11520
  let t = !this.playbackSource.isActivated || this.playbackSource.isPaused;
@@ -11634,7 +11636,7 @@ var fy = class {
11634
11636
  else if (this.logger.debug("Suspending"), this.suspend(), this.shouldAllowBackgroundPlayback(this.channelId)) {
11635
11637
  var t, n, r;
11636
11638
  (t = this.modules.decoder) == null || t.enableBackgroundTimers(), this.modules.connection.unsuspend(), this.modules.sync.unsuspend(), (n = this.modules.decoder) == null || n.unsuspend(), (r = this.modules.canvasModule) == null || r.unsuspend(), this.scheduleInactivityDisconnect();
11637
- } else this.modules.decoder ? this.disconnectForInactivePage() : this.scheduleInactivityDisconnect();
11639
+ } else this.disconnectForInactivePage(this.isUserPaused ? "Background playback paused" : "Background playback disabled");
11638
11640
  }), this.emitter.on("pageshow", (e) => {
11639
11641
  if (!e.persisted || this.isUserPaused) return;
11640
11642
  let t = this.shouldAllowBackgroundPlayback(this.channelId), n = document.visibilityState === "visible";
@@ -12145,7 +12147,13 @@ var fy = class {
12145
12147
  }), this.isSuspended = !0);
12146
12148
  }
12147
12149
  unsuspend() {
12148
- this.isSuspended && (this.resumeModules(), this.isSuspended = !1);
12150
+ if (this.isSuspended) {
12151
+ if (this.isHiddenWithBackgroundPlayDisabled()) {
12152
+ this.logger.debug("Deferring resume until the page is visible");
12153
+ return;
12154
+ }
12155
+ this.resumeModules(), this.isSuspended = !1;
12156
+ }
12149
12157
  }
12150
12158
  alignSizeAndBitRate(e) {
12151
12159
  let t = this.modules.constraintCap.constrainSubscription(O(O({}, e), {}, {