@vindral/web-sdk 4.5.1-26-gf419005e4 → 4.5.1-27-ga7e48e0ae

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.
@@ -3688,7 +3688,7 @@ var ks = (e) => {
3688
3688
  this.element.muted = this._userProvidedMuted, this._play().catch(o);
3689
3689
  }), e(this, "play", () => {
3690
3690
  this.element.muted = this._userProvidedMuted, this._play().catch((e) => {
3691
- if (e instanceof Error) {
3691
+ if (e instanceof Error && e.name !== "AbortError") {
3692
3692
  let t = new h("Media Play Error", {
3693
3693
  source: e,
3694
3694
  isFatal: !1,
@@ -8861,10 +8861,10 @@ var X_ = (e, t) => `${e}\u0000${t == null ? "" : t}`, Z_ = (e, t, n, r) => e ===
8861
8861
  }
8862
8862
  }, lv, uv = class {
8863
8863
  constructor(t) {
8864
- e(this, "emitter", void 0), e(this, "isVisibleCount", 0), e(this, "isHiddenCount", 0), e(this, "isOnlineCount", 0), e(this, "isOfflineCount", 0), e(this, "isActive", document.visibilityState === "visible"), e(this, "unload", () => {
8865
- document.removeEventListener("visibilitychange", this.onVisibilityChanged), window.removeEventListener("pageshow", this.onPageShow), window.removeEventListener("pagehide", this.onPageHide), window.removeEventListener("online", this.onOnline), window.removeEventListener("offline", this.onOffline);
8864
+ e(this, "emitter", void 0), e(this, "isVisibleCount", 0), e(this, "isHiddenCount", 0), e(this, "isOnlineCount", 0), e(this, "isOfflineCount", 0), e(this, "isActive", document.visibilityState === "visible"), e(this, "isBehindAnotherApp", !1), e(this, "unload", () => {
8865
+ this.emitter.off("fullscreen app switch", this.onFullscreenAppSwitch), window.removeEventListener("focus", this.onVisibilityChanged), document.removeEventListener("visibilitychange", this.onVisibilityChanged), window.removeEventListener("pageshow", this.onPageShow), window.removeEventListener("pagehide", this.onPageHide), window.removeEventListener("online", this.onOnline), window.removeEventListener("offline", this.onOffline);
8866
8866
  }), e(this, "load", () => {
8867
- document.addEventListener("visibilitychange", this.onVisibilityChanged), window.addEventListener("pageshow", this.onPageShow), window.addEventListener("pagehide", this.onPageHide), window.addEventListener("online", this.onOnline), window.addEventListener("offline", this.onOffline);
8867
+ this.emitter.on("fullscreen app switch", this.onFullscreenAppSwitch), window.addEventListener("focus", this.onVisibilityChanged), document.addEventListener("visibilitychange", this.onVisibilityChanged), window.addEventListener("pageshow", this.onPageShow), window.addEventListener("pagehide", this.onPageHide), window.addEventListener("online", this.onOnline), window.addEventListener("offline", this.onOffline);
8868
8868
  }), e(this, "unsuspend", () => {}), e(this, "getStatistics", () => {
8869
8869
  var e, t, n, r, i;
8870
8870
  return {
@@ -8881,9 +8881,11 @@ var X_ = (e, t) => `${e}\u0000${t == null ? "" : t}`, Z_ = (e, t, n, r) => e ===
8881
8881
  navigatorDownlink: (i = navigator.connection) == null ? void 0 : i.downlink
8882
8882
  };
8883
8883
  }), e(this, "onOnline", () => this.isOnlineCount++), e(this, "onOffline", () => this.isOfflineCount++), e(this, "onPageShow", (e) => {
8884
- this.emitter.emit("pageshow", e), this.setIsActive(document.visibilityState === "visible");
8884
+ this.emitter.emit("pageshow", e), this.onVisibilityChanged();
8885
8885
  }), e(this, "onPageHide", (e) => this.emitter.emit("pagehide", e)), e(this, "onVisibilityChanged", () => {
8886
- this.setIsActive(document.visibilityState === "visible");
8886
+ this.isBehindAnotherApp = !1, this.setIsActive(this.isVisible);
8887
+ }), e(this, "onFullscreenAppSwitch", () => {
8888
+ this.isBehindAnotherApp = !0, this.setIsActive(!1);
8887
8889
  }), e(this, "setIsActive", (e) => {
8888
8890
  e !== this.isActive && (this.emitter.emit("page active", e), e ? this.isVisibleCount++ : this.isHiddenCount++), this.isActive = e;
8889
8891
  }), this.emitter = t;
@@ -8892,7 +8894,7 @@ var X_ = (e, t) => `${e}\u0000${t == null ? "" : t}`, Z_ = (e, t, n, r) => e ===
8892
8894
  return navigator.onLine;
8893
8895
  }
8894
8896
  get isVisible() {
8895
- return document.visibilityState === "visible";
8897
+ return document.visibilityState === "visible" && !this.isBehindAnotherApp;
8896
8898
  }
8897
8899
  };
8898
8900
  lv = uv, e(uv, "create", (e) => new lv(e));
@@ -9147,11 +9149,13 @@ var xv, Sv = 150, Cv = 400, wv = (e) => e === void 0 ? 5 : e <= Sv ? 1 : e <= Cv
9147
9149
  })), e(this, "suspend", () => {
9148
9150
  this.setGain(0);
9149
9151
  }), e(this, "unsuspend", () => {
9150
- var e;
9151
9152
  if (this.setGain(this._volume), !Ze()) {
9152
9153
  this.resume().catch(this.onUnsuspendFailure);
9153
9154
  return;
9154
9155
  }
9156
+ this.restartContext();
9157
+ }), e(this, "restartContext", () => {
9158
+ var e;
9155
9159
  this.ignoreSuspendCalls = !!this.audio, (e = this.audio) == null || e.suspend().then(t(function* () {
9156
9160
  yield c.resume(), c.ignoreSuspendCalls = !1;
9157
9161
  })).catch(this.onUnsuspendFailure);
@@ -9231,7 +9235,11 @@ var xv, Sv = 150, Cv = 400, wv = (e) => e === void 0 ? 5 : e <= Sv ? 1 : e <= Cv
9231
9235
  return (e = this.audio) == null || e.unload(), this.audio = new bv(), this.audio.on("state", (e) => {
9232
9236
  this.logger.info("AudioContext state change", { state: e }), e === "running" && (this._muted = this._userProvidedMuted, this.setGain(this._volume)), !this.ignoreSuspendCalls && this.emit("state change", e);
9233
9237
  }), this.audio.on("stuck", () => {
9234
- this.reInitWhenStuck && (this.logger.info("Re-init audio context"), this.setupContext(), this.resume().catch(o), this.emit("stuck"));
9238
+ if (!this.reInitWhenStuck) {
9239
+ this.restartContext();
9240
+ return;
9241
+ }
9242
+ this.logger.info("Re-init audio context"), this.setupContext(), this.resume().catch(o), this.emit("stuck");
9235
9243
  }), (t = this.gainNode) == null || t.disconnect(), this.gainNode = this.audio.createGain(), this.setGain(this._volume), this.startTime = this.audio.currentTime, (n = this.splitter) == null || n.disconnect(), this.splitter = this.audio.createSplitter(), this.audio;
9236
9244
  }), e(this, "setGain", (e) => {
9237
9245
  this.gainNode && (this.gainNode.gain.value = this._muted ? 0 : e);
@@ -9643,30 +9651,49 @@ Pv = Rv, e(Rv, "create", (e, t, n) => new Pv(e, t, n)), e(Rv, "isSupported", ()
9643
9651
  //#endregion
9644
9652
  //#region ../../libs/web-sdk/src/modules/ModernCanvasModule.ts
9645
9653
  var zv, Bv = class {
9646
- constructor(t, n, r, i, { muted: a, volume: s, type: c, poster: l, offscreenCanvas: u, bufferTime: d, backgroundPlaybackEnabled: f }) {
9647
- e(this, "logger", void 0), e(this, "emitter", void 0), e(this, "mediaElement", void 0), e(this, "audioPlayer", void 0), e(this, "videoPlayer", void 0), e(this, "pool", void 0), e(this, "isDisconnected", !0), e(this, "_userProvidedMuted", !1), e(this, "timers", new M()), e(this, "offscreenCanvas", void 0), e(this, "videoTrack", void 0), e(this, "canvasCaptureTracks", []), e(this, "backgroundPlaybackEnabled", void 0), e(this, "nativeTracksByLanguage", /* @__PURE__ */ new Map()), e(this, "nativeCuesByLanguage", /* @__PURE__ */ new Map()), e(this, "lastCanvasCueTexts", []), e(this, "isIOSNativeFullscreen", !1), e(this, "isSyncingNativeTextTracks", !1), e(this, "renderCanvasSubtitlesInNativeFullscreen", (() => {
9654
+ constructor(t, n, r, i, { muted: a, volume: s, type: c, poster: l, offscreenCanvas: u, bufferTime: d, backgroundPlaybackEnabled: f, splitAudio: p }) {
9655
+ if (e(this, "logger", void 0), e(this, "emitter", void 0), e(this, "mediaElement", void 0), e(this, "sound", void 0), e(this, "wantsPlay", void 0), e(this, "audioPlayer", void 0), e(this, "videoPlayer", void 0), e(this, "pool", void 0), e(this, "isDisconnected", !0), e(this, "_userProvidedMuted", !1), e(this, "timers", new M()), e(this, "offscreenCanvas", void 0), e(this, "videoTrack", void 0), e(this, "canvasCaptureTracks", []), e(this, "backgroundPlaybackEnabled", void 0), e(this, "nativeTracksByLanguage", /* @__PURE__ */ new Map()), e(this, "nativeCuesByLanguage", /* @__PURE__ */ new Map()), e(this, "lastCanvasCueTexts", []), e(this, "isIOSNativeFullscreen", !1), e(this, "isSyncingNativeTextTracks", !1), e(this, "renderCanvasSubtitlesInNativeFullscreen", (() => {
9648
9656
  let e = st().platform;
9649
9657
  return e.isIOS && e.iosVersion <= 16;
9650
9658
  })()), e(this, "volumeState", void 0), e(this, "textTracks", new kv()), e(this, "reset", () => {}), e(this, "load", () => {
9651
- this.mediaElement.load(), this.emitter.on("decoded frame", this.onDecodedFrame), this.emitter.on("flush buffers", this.flushBuffers), this.emitter.on("ios-hack: reset size", this.resetCanvasSize), this.emitter.on("enter picture in picture", this.onEnterIOSHack), this.emitter.on("exit picture in picture", this.onExitIOSHack), this.element().element.textTracks.addEventListener("change", this.onNativeTextTrackChange), this.element().element.addEventListener("webkitendfullscreen", this.onExitIOSHack), this.element().element.addEventListener("webkitbeginfullscreen", this.onEnterIOSHack), this.videoPlayer.load(), this.timers.setInterval(this.syncNativeTextTracks, 100);
9659
+ this.mediaElement.load(), this.sound && (this.sound.load(), document.body.appendChild(this.sound.element), this.mediaElement.element.addEventListener("pause", this.onVideoPause), this.mediaElement.element.addEventListener("play", this.onVideoPlay), window.addEventListener("focus", this.onWindowFocus)), this.emitter.on("decoded frame", this.onDecodedFrame), this.emitter.on("flush buffers", this.flushBuffers), this.emitter.on("ios-hack: reset size", this.resetCanvasSize), this.emitter.on("enter picture in picture", this.onEnterIOSHack), this.emitter.on("exit picture in picture", this.onExitIOSHack), this.element().element.textTracks.addEventListener("change", this.onNativeTextTrackChange), this.element().element.addEventListener("webkitendfullscreen", this.onExitIOSHack), this.element().element.addEventListener("webkitbeginfullscreen", this.onEnterIOSHack), this.videoPlayer.load(), this.timers.setInterval(this.syncNativeTextTracks, 100);
9652
9660
  }), e(this, "unload", () => {
9653
9661
  this.emitter.off("target buffer time", this.onTargetBufferTime), this.emitter.off("decoded frame", this.onDecodedFrame), this.emitter.off("flush buffers", this.flushBuffers), this.emitter.off("ios-hack: reset size", this.resetCanvasSize), this.emitter.off("enter picture in picture", this.onEnterIOSHack), this.emitter.off("exit picture in picture", this.onExitIOSHack), this.element().element.textTracks.removeEventListener("change", this.onNativeTextTrackChange), this.element().element.removeEventListener("webkitendfullscreen", this.onExitIOSHack), this.element().element.removeEventListener("webkitbeginfullscreen", this.onEnterIOSHack);
9654
9662
  for (let e of this.nativeTracksByLanguage.keys()) this.clearNativeCues(e);
9655
- this.nativeTracksByLanguage.clear(), this.nativeCuesByLanguage.clear(), this.mediaElement.unload(), this.timers.unload(), this.audioPlayer.unload(), this.videoPlayer.unload();
9663
+ this.nativeTracksByLanguage.clear(), this.nativeCuesByLanguage.clear(), this.sound && (this.mediaElement.element.removeEventListener("pause", this.onVideoPause), this.mediaElement.element.removeEventListener("play", this.onVideoPlay), window.removeEventListener("focus", this.onWindowFocus), this.sound.pause(), this.sound.element.srcObject = null, this.sound.unload(), this.sound.element.remove()), this.mediaElement.unload(), this.timers.unload(), this.audioPlayer.unload(), this.videoPlayer.unload();
9656
9664
  }), e(this, "suspend", () => {
9657
9665
  this.videoPlayer.suspend(), this.audioPlayer.suspend();
9658
9666
  }), e(this, "unsuspend", () => {
9659
9667
  this.videoPlayer.unsuspend(), this.audioPlayer.unsuspend();
9660
- }), e(this, "element", () => this.mediaElement), e(this, "getStatistics", () => D(D({}, this.videoPlayer.getStatistics()), {}, { audioContextState: this.audioPlayer.contextState })), e(this, "activateAudioPlayer", () => (this.isDisconnected && this.connectStreams(), this.audioPlayer.play())), e(this, "flushBuffers", () => {
9668
+ }), e(this, "element", () => this.mediaElement), e(this, "elements", () => this.sound ? [this.mediaElement, this.sound] : [this.mediaElement]), e(this, "getStatistics", () => D(D({}, this.videoPlayer.getStatistics()), {}, { audioContextState: this.audioPlayer.contextState })), e(this, "activateAudioPlayer", () => (this.isDisconnected && this.connectStreams(), this.audioPlayer.play())), e(this, "flushBuffers", () => {
9661
9669
  this.audioPlayer.flushBuffer();
9662
9670
  }), e(this, "onTargetBufferTime", (e) => {
9663
9671
  this.audioPlayer.bufferTime = e;
9664
9672
  }), e(this, "resetCanvasSize", () => {
9665
9673
  this.videoPlayer.resetSize();
9674
+ }), e(this, "onVideoPause", () => {
9675
+ this.mediaElement.element.paused && (this.emitPlaybackState(), this.wantsPlay && this.timers.setTimeout(this.isIOSNativeFullscreen ? this.reportFullscreenPause : this.restartVideoIfWanted, 400));
9676
+ }), e(this, "onVideoPlay", () => {
9677
+ if (!this.mediaElement.element.paused) {
9678
+ if (!this.wantsPlay) {
9679
+ this.isIOSNativeFullscreen ? this.emitter.emit("native control", "play") : this.mediaElement.pause();
9680
+ return;
9681
+ }
9682
+ this.emitPlaybackState();
9683
+ }
9666
9684
  }), e(this, "onEnterIOSHack", () => {
9667
9685
  this.isIOSNativeFullscreen = !0, this.mediaElement._iosHackEnterPiPMode();
9668
9686
  }), e(this, "onExitIOSHack", () => {
9669
- this.isIOSNativeFullscreen = !1, this.clearCanvasCues(), this.mediaElement._iosHackExitPiPMode();
9687
+ this.isIOSNativeFullscreen = !1, this.clearCanvasCues(), this.mediaElement._iosHackExitPiPMode(), this.sound && this.restartVideoIfWanted();
9688
+ }), e(this, "reportFullscreenPause", () => {
9689
+ !this.isIOSNativeFullscreen || !this.wantsPlay || !this.mediaElement.element.paused || (Ct(this.mediaElement.element) === "picture-in-picture" || document.hasFocus() ? this.emitter.emit("native control", "pause") : this.emitter.emit("fullscreen app switch"));
9690
+ }), e(this, "onWindowFocus", () => {
9691
+ this.isIOSNativeFullscreen && this.wantsPlay && this.mediaElement.element.paused && this.mediaElement.tryPlay();
9692
+ }), e(this, "lastPlaybackState", void 0), e(this, "emitPlaybackState", () => {
9693
+ let e = this.isPaused ? "paused" : "playing";
9694
+ e !== this.lastPlaybackState && (this.lastPlaybackState = e, this.emitter.emit("media element state", e));
9695
+ }), e(this, "restartVideoIfWanted", () => {
9696
+ this.wantsPlay && this.mediaElement.element.paused && !this.isIOSNativeFullscreen && document.visibilityState === "visible" && this.mediaElement.tryPlay();
9670
9697
  }), e(this, "onDecodedFrame", (e) => {
9671
9698
  try {
9672
9699
  this.audioPlayer.onDecodedFrame(e);
@@ -9685,10 +9712,10 @@ var zv, Bv = class {
9685
9712
  this.logger.info(`Connecting streams using ${this.offscreenCanvas ? "OffscreenCanvas" : "VideoPlayer"} canvas (${e.width}x${e.height})`);
9686
9713
  let t = this.videoTrack ? [this.videoTrack] : e.captureStream().getTracks(), n = this.canvasCaptureTracks;
9687
9714
  this.canvasCaptureTracks = this.videoTrack ? [] : t;
9688
- let r = this.audioPlayer.useMediaStreamDestination().stream, i = [...t, ...r.getTracks()];
9715
+ let r = this.audioPlayer.useMediaStreamDestination().stream, i = this.sound ? t : [...t, ...r.getTracks()];
9689
9716
  this.logger.info(`Video tracks: ${t.length} (${this.videoTrack ? "worker track" : "canvas capture"}), Audio tracks: ${r.getTracks().length}`);
9690
9717
  for (let e of n) e.stop();
9691
- this.mediaElement.element.srcObject = new MediaStream(i), this.isDisconnected = !1;
9718
+ this.mediaElement.element.srcObject = new MediaStream(i), this.sound && this.sound.element.srcObject !== r && (this.sound.element.srcObject = r), this.isDisconnected = !1;
9692
9719
  }), e(this, "setVideoTrack", (e) => {
9693
9720
  this.videoTrack !== e && (this.videoTrack = e, this.reconnectCanvasStream());
9694
9721
  }), e(this, "setOffscreenCanvas", (e) => {
@@ -9764,43 +9791,48 @@ var zv, Bv = class {
9764
9791
  }), e(this, "applyVisibilityMutePolicy", () => {
9765
9792
  if (!this.audioPlayer.isContextRunning) return;
9766
9793
  let e = document.visibilityState === "hidden";
9767
- this.mediaElement.muted = this._userProvidedMuted || e && !this.backgroundPlaybackEnabled;
9794
+ this.soundElement.muted = this._userProvidedMuted || e && !this.backgroundPlaybackEnabled;
9768
9795
  }), this.logger = n, this.emitter = t, this.pool = r, this._userProvidedMuted = a, this.offscreenCanvas = u, this.backgroundPlaybackEnabled = f == null ? !1 : f, this.emitter.on("target buffer time", this.onTargetBufferTime), this.mediaElement = new As({
9769
9796
  poster: l,
9770
9797
  type: c,
9771
- muted: a,
9798
+ muted: p ? !0 : a,
9772
9799
  volume: s,
9773
9800
  autoplay: !1,
9774
9801
  logger: this.logger.createContext("MediaElement")
9775
- }), this.mediaElement.on("volume state", (e) => {
9802
+ }), p && (this.sound = new As({
9803
+ type: "audio",
9804
+ muted: a,
9805
+ volume: s,
9806
+ autoplay: !1,
9807
+ logger: this.logger.createContext("SoundElement")
9808
+ }), this.sound.element.style.display = "none", this.sound.element.setAttribute("aria-hidden", "true")), this.soundElement.on("volume state", (e) => {
9776
9809
  this.updateVolumeState(), !e.isMuted && !this.audioPlayer.isContextRunning && this.activateAudioPlayer().catch(o), e.isMuted || (this._userProvidedMuted = !1);
9777
- }), this.mediaElement.on("media element state", (e) => {
9778
- e === "paused" && this.audioPlayer.flushBuffer(), this.audioPlayer.sinkPaused = e === "paused", this.emitter.emit("media element state", e);
9779
- }), this.audioPlayer = Tv.create(this.logger.createContext("AudioPlayerModule"), i, {
9810
+ }), this.soundElement.on("media element state", (e) => {
9811
+ e === "paused" && this.audioPlayer.flushBuffer(), this.audioPlayer.sinkPaused = e === "paused", this.emitPlaybackState();
9812
+ }), this.sound) for (let e of this.elements()) e.on("needs user input", (e) => this.emitter.emit("needs user input", e)), e.on("error", (e) => this.emitter.emit("error", e));
9813
+ this.audioPlayer = Tv.create(this.logger.createContext("AudioPlayerModule"), i, {
9780
9814
  muted: !1,
9781
9815
  reInitWhenStuck: !1,
9782
9816
  bufferTime: d
9783
- }), this.audioPlayer.on("stuck", () => {
9784
- this.isDisconnected = !0;
9785
9817
  }), this.audioPlayer.on("state change", (e) => {
9786
- e === "suspended" || e === "interrupted" ? this.mediaElement.muted = !0 : e === "running" && this.applyVisibilityMutePolicy(), this.updateVolumeState();
9818
+ e === "suspended" || e === "interrupted" ? this.soundElement.muted = !0 : e === "running" && this.applyVisibilityMutePolicy(), this.updateVolumeState();
9787
9819
  }), this.videoPlayer = Dv.create(this.logger.createContext("VideoPlayerModule"), this.audioPlayer, this.pool, this.mediaElement.element, () => this.reconnectCanvasStream(), this.onVideoPlayerError);
9788
9820
  }
9789
9821
  get volume() {
9790
- return this.mediaElement.volume;
9822
+ return this.soundElement.volume;
9791
9823
  }
9792
9824
  set volume(e) {
9793
- this.mediaElement.volume = e;
9825
+ this.soundElement.volume = e;
9794
9826
  }
9795
9827
  get muted() {
9796
- return this.mediaElement.muted || this.audioPlayer.muted;
9828
+ return this.soundElement.muted || this.audioPlayer.muted;
9797
9829
  }
9798
9830
  get userMuted() {
9799
- return this.audioPlayer.isContextRunning ? this.mediaElement.muted : this._userProvidedMuted;
9831
+ return this.audioPlayer.isContextRunning ? this.soundElement.muted : this._userProvidedMuted;
9800
9832
  }
9801
9833
  set muted(e) {
9802
9834
  let t = this.muted;
9803
- this._userProvidedMuted = e, this.mediaElement.muted = e, !e && t && this.activateAudioPlayer().catch(o);
9835
+ this._userProvidedMuted = e, this.soundElement.muted = e, !e && t && this.activateAudioPlayer().catch(o);
9804
9836
  }
9805
9837
  get currentTime() {
9806
9838
  return this.audioPlayer.currentTime;
@@ -9821,7 +9853,11 @@ var zv, Bv = class {
9821
9853
  return this.mediaElement.totalSeekTime;
9822
9854
  }
9823
9855
  get isPaused() {
9824
- return this.mediaElement.isPaused;
9856
+ return this.sound ? this.wantsPlay === !1 || this.sound.isPaused && this.mediaElement.element.paused : this.mediaElement.isPaused;
9857
+ }
9858
+ get isPlayingAsRequested() {
9859
+ let e = this.soundElement.element;
9860
+ return !this.wantsPlay || !e.paused && e.muted === this._userProvidedMuted;
9825
9861
  }
9826
9862
  get isSeeking() {
9827
9863
  return this.mediaElement.isSeeking;
@@ -9830,16 +9866,23 @@ var zv, Bv = class {
9830
9866
  return this.audioPlayer.audioNode;
9831
9867
  }
9832
9868
  play() {
9833
- let e = this._userProvidedMuted;
9869
+ var e;
9870
+ this.wantsPlay = !0;
9871
+ let t = this._userProvidedMuted;
9834
9872
  return this.activateAudioPlayer().catch(() => {
9835
- e || this.emitter.emit("needs user input", {
9873
+ t || this.emitter.emit("needs user input", {
9836
9874
  forAudio: !0,
9837
9875
  forVideo: !1
9838
9876
  });
9839
- }), this.mediaElement.play();
9877
+ }), (e = this.sound) == null || e.play(), this.mediaElement.play();
9840
9878
  }
9841
9879
  pause() {
9842
- this.mediaElement.pause();
9880
+ var e;
9881
+ this.wantsPlay = !1, (e = this.sound) == null || e.pause(), this.mediaElement.pause();
9882
+ }
9883
+ get soundElement() {
9884
+ var e;
9885
+ return (e = this.sound) == null ? this.mediaElement : e;
9843
9886
  }
9844
9887
  get canvasCuesEnabled() {
9845
9888
  return this.renderCanvasSubtitlesInNativeFullscreen && !this.offscreenCanvas;
@@ -11228,11 +11271,11 @@ Sy = Ty, e(Ty, "create", (e, t, n, r) => new Sy(e, t, n, r));
11228
11271
  //#region ../../libs/web-sdk/src/modules/UnpauseModule.ts
11229
11272
  var Ey, Dy = class {
11230
11273
  constructor(t, n, r) {
11231
- e(this, "logger", void 0), e(this, "element", void 0), e(this, "documentState", void 0), e(this, "timers", new M()), e(this, "unload", () => {
11274
+ e(this, "logger", void 0), e(this, "elements", void 0), e(this, "documentState", void 0), e(this, "timers", new M()), e(this, "unload", () => {
11232
11275
  this.timers.unload();
11233
11276
  }), e(this, "unpause", () => {
11234
- this.element.userHasProvidedInput && this.element.isPaused && this.documentState.isVisible && this.documentState.isOnline && (this.logger.debug("Unpause video"), this.element.tryPlay());
11235
- }), this.logger = t, this.element = n, this.documentState = r, this.timers.setInterval(this.unpause, 100);
11277
+ if (!(!this.documentState.isVisible || !this.documentState.isOnline)) for (let e of this.elements) e.userHasProvidedInput && e.isPaused && (this.logger.debug("Unpause media element"), e.tryPlay());
11278
+ }), this.logger = t, this.elements = n, this.documentState = r, this.timers.setInterval(this.unpause, 100);
11236
11279
  }
11237
11280
  };
11238
11281
  Ey = Dy, e(Dy, "create", (e, t, n) => new Ey(e, t, n));
@@ -11805,7 +11848,7 @@ var Ay = class {
11805
11848
  let e = this.modules.canvasModule instanceof Bv ? !0 : void 0;
11806
11849
  return D({
11807
11850
  uptime: this.uptime,
11808
- version: "4.5.1-26-gf419005e4",
11851
+ version: "4.5.1-27-ga7e48e0ae",
11809
11852
  clientId: this.clientId,
11810
11853
  sessionId: this.sessionId,
11811
11854
  channelId: this.channelId,
@@ -11872,7 +11915,7 @@ var Ay = class {
11872
11915
  f && this.logger.warn("Option mseEnabled is deprecated and will be removed in a future release. Use decoders instead (e.g. decoders: [\"wasm\"])."), f && !p && i.mseEnabled === !1 && this.options.set("decoders", ["wasm"]);
11873
11916
  let g = $v.create(this.emitter, this.logger.createContext("PictureInPictureModule")), _ = this.options.get("mediaSessionEnabled") ? Rv.create(this.emitter, this.logger.createContext("MediaSessionModule"), {
11874
11917
  metadata: this.options.get("mediaSessionMetadata"),
11875
- decoy: this.willUseMediaSource() ? void 0 : qs.create(this.logger.createContext("AudioFocusDecoy"), this.yieldToInterruption),
11918
+ decoy: this.willUseMediaSource() || this.usesSplitCanvasAudio() ? void 0 : qs.create(this.logger.createContext("AudioFocusDecoy"), this.yieldToInterruption),
11876
11919
  isMuted: () => this.playbackSource.userMuted,
11877
11920
  isHidden: () => !this.modules.documentState.isVisible,
11878
11921
  isSinkPaused: () => this.isMediaElementPaused,
@@ -11904,7 +11947,7 @@ var Ay = class {
11904
11947
  logger: this.logger.createContext("MediaElement"),
11905
11948
  poster: C
11906
11949
  });
11907
- e.on("buffer state", (e) => this.onMediaElementBufferState(e, se)), e.on("needs user input", (e) => this.emitter.emit("needs user input", e)), e.on("volume state", (e) => this.emitter.emit("volume state", e)), e.on("media element state", (e) => this.onMediaElementState(e)), this.element = e.element, this.playbackSource = e, Gr.isSupported() && this.encryptedMediaExtensions.attach(e.element), se = Gv.create(this.logger.createContext("MseModule"), this.emitter, this.element), this.options.get("pauseSupportEnabled") || (le = Dy.create(this.logger.createContext("UnpauseModule"), e, ae)), this.options.get("pictureInPictureEnabled") && this.emitter.emit("add picture in picture listener", { element: e.element });
11950
+ e.on("buffer state", (e) => this.onMediaElementBufferState(e, se)), e.on("needs user input", (e) => this.emitter.emit("needs user input", e)), e.on("volume state", (e) => this.emitter.emit("volume state", e)), e.on("media element state", (e) => this.onMediaElementState(e)), this.element = e.element, this.playbackSource = e, Gr.isSupported() && this.encryptedMediaExtensions.attach(e.element), se = Gv.create(this.logger.createContext("MseModule"), this.emitter, this.element), this.options.get("pauseSupportEnabled") || (le = Dy.create(this.logger.createContext("UnpauseModule"), [e], ae)), this.options.get("pictureInPictureEnabled") && this.emitter.emit("add picture in picture listener", { element: e.element });
11908
11951
  } else if (this.streamsToMediaElement()) {
11909
11952
  let e = Bv.create(this.emitter, this.logger.createContext("ModernCanvasModule"), this.pool, this, {
11910
11953
  type: this.options.get("media") === "audio" ? "audio" : "video",
@@ -11913,11 +11956,12 @@ var Ay = class {
11913
11956
  poster: C,
11914
11957
  offscreenCanvas: this.offscreenCanvasElement,
11915
11958
  bufferTime: this.options.get("minBufferTime"),
11916
- backgroundPlaybackEnabled: this.isBackgroundPlayEnabled(this.channelId)
11917
- }), t = e.element();
11918
- this.element = t.element, this.playbackSource = e, ue = e;
11919
- let n = this.browser.platform.isIOS && this.browser.platform.iosVersion <= 15;
11920
- this.options.get("pictureInPictureEnabled") && !n && this.emitter.emit("add picture in picture listener", { element: this.element }), this.options.get("pauseSupportEnabled") || (le = Dy.create(this.logger.createContext("UnpauseModule"), t, ae));
11959
+ backgroundPlaybackEnabled: this.isBackgroundPlayEnabled(this.channelId),
11960
+ splitAudio: this.usesSplitCanvasAudio()
11961
+ });
11962
+ this.element = e.element().element, this.playbackSource = e, ue = e;
11963
+ let t = this.browser.platform.isIOS && this.browser.platform.iosVersion <= 15;
11964
+ this.options.get("pictureInPictureEnabled") && !t && this.emitter.emit("add picture in picture listener", { element: this.element }), this.options.get("pauseSupportEnabled") || (le = Dy.create(this.logger.createContext("UnpauseModule"), e.elements(), ae));
11921
11965
  } else {
11922
11966
  let e;
11923
11967
  e = Nv.create(this.emitter, this.logger.createContext("LegacyCanvasModule"), this.pool, this, this.options.get("muted") || this.options.get("media") === "video", this.options.get("volume"), () => {
@@ -11973,9 +12017,11 @@ var Ay = class {
11973
12017
  }), this.emitter.on("exit picture in picture", () => {
11974
12018
  var e;
11975
12019
  return (e = this.modules.decoder) == null ? void 0 : e.setVideoRenderingEnabled(this.modules.documentState.isVisible);
11976
- }), this.emitter.on("media session: request play", () => this.fromNativeControls("play")), this.emitter.on("media session: request pause", () => this.fromNativeControls("pause")), this.emitter.on("media session: request stop", () => this.fromNativeControls("pause")), this.emitter.on("page active", (e) => {
12020
+ }), this.emitter.on("media session: request play", () => this.fromNativeControls("play")), this.emitter.on("media session: request pause", () => this.fromNativeControls("pause")), this.emitter.on("media session: request stop", () => this.fromNativeControls("pause")), this.emitter.on("native control", (e) => {
12021
+ this.options.get("pauseSupportEnabled") && this.fromNativeControls(e);
12022
+ }), this.emitter.on("page active", (e) => {
11977
12023
  var t, n;
11978
- if ((t = this.modules.decoder) == null || t.setVideoRenderingEnabled(this.isVideoOnScreen(e)), e) this.clearInactivityDisconnect(), this.isUserPaused || (this.logger.debug("Unsuspending"), this.unsuspend());
12024
+ if ((t = this.modules.decoder) == null || t.setVideoRenderingEnabled(this.isVideoOnScreen(e)), e) this.clearInactivityDisconnect(), this.isUserPaused || (this.logger.debug("Unsuspending"), this.unsuspend(), this.usesSplitCanvasAudio() && this.playbackSource.isPlayingAsRequested === !1 && (this.logger.debug("Playing again after show"), this.play()));
11979
12025
  else if (this.clearVisiblePauseDisconnect(), this.logger.debug("Suspending"), this.suspend(), this.shouldAllowBackgroundPlayback(this.channelId)) {
11980
12026
  var r, i, a;
11981
12027
  (r = this.modules.decoder) == null || r.enableBackgroundTimers(), this.modules.connection.unsuspend(), this.modules.sync.unsuspend(), (i = this.modules.decoder) == null || i.unsuspend(), (a = this.modules.canvasModule) == null || a.unsuspend(), this.scheduleInactivityDisconnect();
@@ -12528,6 +12574,9 @@ var Ay = class {
12528
12574
  resolvedDecoder(e) {
12529
12575
  return Iy(this.options.get("decoders", e), this.browser.supportsMediaSource, this.options.get("drm"));
12530
12576
  }
12577
+ usesSplitCanvasAudio() {
12578
+ return !this.willUseMediaSource() && this.options.get("streamToMediaElementEnabled") && At(this.browser) && this.options.get("media") !== "audio" && this.options.get("media") !== "video" && this.browser.platform.isIOS;
12579
+ }
12531
12580
  isWebKitCanvasPath() {
12532
12581
  return !this.willUseMediaSource() && this.browser.platform.isWebKit;
12533
12582
  }
@@ -1,5 +1,5 @@
1
1
  import { n as e, t } from "./BsfwXDui.js";
2
- import { _ as n, a as r, c as i, d as a, f as o, g as s, h as c, i as l, l as u, m as ee, n as d, o as te, p as ne, r as re, s as ie, t as ae, u as oe, v as se } from "./BR0DDziv.js";
2
+ import { _ as n, a as r, c as i, d as a, f as o, g as s, h as c, i as l, l as u, m as ee, n as d, o as te, p as ne, r as re, s as ie, t as ae, u as oe, v as se } from "./BgS0aefK.js";
3
3
  import { F as ce } from "./BBVSf5AB.js";
4
4
  import { i as f, n as p, r as m, t as h } from "./DSw1XhvD.js";
5
5
  import { c as le, n as ue, t as de } from "./BOdyvABa.js";
package/cast-sender.d.ts CHANGED
@@ -332,6 +332,9 @@ interface Options {
332
332
  * This enables platform media features such as fullscreen and picture-in-picture
333
333
  * for non-MSE playback by routing the canvas output through a `<video>` element.
334
334
  *
335
+ * On iOS the audio then plays from its own element, so it continues in the background and under
336
+ * lock. After an extended pause from the lock screen, reopening Safari may be required to resume.
337
+ *
335
338
  * Disabled by default.
336
339
  */
337
340
  streamToMediaElementEnabled?: boolean;
package/core.d.ts CHANGED
@@ -428,6 +428,9 @@ export interface Options {
428
428
  * This enables platform media features such as fullscreen and picture-in-picture
429
429
  * for non-MSE playback by routing the canvas output through a `<video>` element.
430
430
  *
431
+ * On iOS the audio then plays from its own element, so it continues in the background and under
432
+ * lock. After an extended pause from the lock screen, reopening Safari may be required to resume.
433
+ *
431
434
  * Disabled by default.
432
435
  */
433
436
  streamToMediaElementEnabled?: boolean;
@@ -1654,6 +1657,7 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1654
1657
  * the page is visible, so a hidden pause is a stop there. Reads the decoder in use.
1655
1658
  */
1656
1659
  private hiddenPauseIsStop;
1660
+ private usesSplitCanvasAudio;
1657
1661
  private isWebKitCanvasPath;
1658
1662
  private holdsDecoyWhilePaused;
1659
1663
  private streamsToMediaElement;
package/core.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as e } from "./BR0DDziv.js";
1
+ import { t as e } from "./BgS0aefK.js";
2
2
  import { a as t, c as n, d as r, f as i, i as a, l as o, n as s, o as c, r as l, s as u } from "./BBVSf5AB.js";
3
3
  export { s as AUTHENTICATION_EXPIRED_CODE, l as AUTHENTICATION_FAILED_CODE, a as CHANNEL_NOT_FOUND_CODE, t as CHANNEL_NOT_LIVE_CODE, c as CONNECTION_FAILED_AFTER_RETRIES_CODE, u as CONNECTION_FAILED_CODE, n as DISCONNECTED_BY_EDGE, o as INACTIVITY_CODE, r as NO_INCOMING_DATA, e as Vindral, i as VindralError };
package/legacy.d.ts CHANGED
@@ -431,6 +431,9 @@ export interface Options {
431
431
  * This enables platform media features such as fullscreen and picture-in-picture
432
432
  * for non-MSE playback by routing the canvas output through a `<video>` element.
433
433
  *
434
+ * On iOS the audio then plays from its own element, so it continues in the background and under
435
+ * lock. After an extended pause from the lock screen, reopening Safari may be required to resume.
436
+ *
434
437
  * Disabled by default.
435
438
  */
436
439
  streamToMediaElementEnabled?: boolean;
@@ -1669,6 +1672,7 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1669
1672
  * the page is visible, so a hidden pause is a stop there. Reads the decoder in use.
1670
1673
  */
1671
1674
  private hiddenPauseIsStop;
1675
+ private usesSplitCanvasAudio;
1672
1676
  private isWebKitCanvasPath;
1673
1677
  private holdsDecoyWhilePaused;
1674
1678
  private streamsToMediaElement;