suada-components 1.8.0 → 1.9.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.
Files changed (39) hide show
  1. package/dist/components/{DailyMotion-SZKPSpD1.js → DailyMotion-B7yDPBbg.js} +1 -1
  2. package/dist/components/{DailyMotion-jrl4eEA1.esm.js → DailyMotion-BmnymjR1.esm.js} +1 -1
  3. package/dist/components/{Facebook-DS0ye_bL.js → Facebook-42iqQU2G.js} +1 -1
  4. package/dist/components/{Facebook-Ha24RKIX.esm.js → Facebook-D9Ak6ZJU.esm.js} +1 -1
  5. package/dist/components/{FilePlayer-B4_DDZXQ.js → FilePlayer-CAnHK0Cd.js} +1 -1
  6. package/dist/components/{FilePlayer-D-n083nK.esm.js → FilePlayer-wg9lyafD.esm.js} +1 -1
  7. package/dist/components/{Kaltura-DAMolg_c.js → Kaltura-Ct6kwbgP.js} +1 -1
  8. package/dist/components/{Kaltura-BlDrsjbp.esm.js → Kaltura-DPaEN-dq.esm.js} +1 -1
  9. package/dist/components/{Mixcloud-B5AIgf8e.esm.js → Mixcloud-BobSN3YI.esm.js} +1 -1
  10. package/dist/components/{Mixcloud-C1z9BVJ8.js → Mixcloud-sBbcL5rG.js} +1 -1
  11. package/dist/components/{Mux-f77ctQXE.esm.js → Mux-B9YP-rFr.esm.js} +1 -1
  12. package/dist/components/{Mux-Bgsc5vvM.js → Mux-Cosy8sFO.js} +1 -1
  13. package/dist/components/{Preview-CKXk6Axz.js → Preview-DiVfo6aa.js} +1 -1
  14. package/dist/components/{Preview-DhMMn7e2.esm.js → Preview-XcTlhHT1.esm.js} +1 -1
  15. package/dist/components/{SoundCloud-DyYFhGe5.esm.js → SoundCloud-BTHoyFWT.esm.js} +1 -1
  16. package/dist/components/{SoundCloud-DHLHmaaB.js → SoundCloud-CIWqB-QW.js} +1 -1
  17. package/dist/components/{Streamable-BDhbB3m3.js → Streamable-9anYiQtU.js} +1 -1
  18. package/dist/components/{Streamable-BBygdIqb.esm.js → Streamable-DsfQCy3p.esm.js} +1 -1
  19. package/dist/components/{Twitch-CAbFCb5f.esm.js → Twitch-D1BOr8hj.esm.js} +1 -1
  20. package/dist/components/{Twitch-ZG7WuoXD.js → Twitch-Dud6e1Rv.js} +1 -1
  21. package/dist/components/VideoPlayer/pipManager.d.ts +60 -0
  22. package/dist/components/VideoPlayer/pipManager.js +272 -0
  23. package/dist/components/VideoPlayer/pipManager.js.map +1 -0
  24. package/dist/components/VideoPlayer/usePlayerControls.js +40 -12
  25. package/dist/components/VideoPlayer/usePlayerControls.js.map +1 -1
  26. package/dist/components/{Vidyard-CkSCnLg5.js → Vidyard-BuOu85uS.js} +1 -1
  27. package/dist/components/{Vidyard-BsU5Ayr6.esm.js → Vidyard-C1csjpQH.esm.js} +1 -1
  28. package/dist/components/{Vimeo-4uslT7bX.esm.js → Vimeo-CHlHIswX.esm.js} +1 -1
  29. package/dist/components/{Vimeo-DKpnTiZ8.js → Vimeo-DrDJ5O9H.js} +1 -1
  30. package/dist/components/{Wistia-BxvIPVO7.esm.js → Wistia-D-eYyONb.esm.js} +1 -1
  31. package/dist/components/{Wistia-DKdMEz2a.js → Wistia-fh9U2CA2.js} +1 -1
  32. package/dist/components/{YouTube-Cd4b1iuA.esm.js → YouTube-CmnnzZvk.esm.js} +1 -1
  33. package/dist/components/{YouTube-JSWV2_hs.js → YouTube-DC2uZ14c.js} +1 -1
  34. package/dist/components/components/VideoPlayer/pipManager.d.ts +60 -0
  35. package/dist/components/{index-BTR541gv.esm.js → index-DKAGRUEW.esm.js} +304 -26
  36. package/dist/components/{index-XiB9Yp2-.js → index-DetZ05pw.js} +304 -26
  37. package/dist/components/index.esm.js +1 -1
  38. package/dist/icons/components/VideoPlayer/pipManager.d.ts +60 -0
  39. package/package.json +1 -1
@@ -81375,7 +81375,7 @@ function requirePlayers () {
81375
81375
  canPlay: import_patterns.canPlay.youtube,
81376
81376
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81377
81377
  /* webpackChunkName: 'reactPlayerYouTube' */
81378
- './YouTube-JSWV2_hs.js'
81378
+ './YouTube-DC2uZ14c.js'
81379
81379
  ); }).then(function (n) { return n.YouTube; }))
81380
81380
  },
81381
81381
  {
@@ -81384,7 +81384,7 @@ function requirePlayers () {
81384
81384
  canPlay: import_patterns.canPlay.soundcloud,
81385
81385
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81386
81386
  /* webpackChunkName: 'reactPlayerSoundCloud' */
81387
- './SoundCloud-DHLHmaaB.js'
81387
+ './SoundCloud-CIWqB-QW.js'
81388
81388
  ); }).then(function (n) { return n.SoundCloud; }))
81389
81389
  },
81390
81390
  {
@@ -81393,7 +81393,7 @@ function requirePlayers () {
81393
81393
  canPlay: import_patterns.canPlay.vimeo,
81394
81394
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81395
81395
  /* webpackChunkName: 'reactPlayerVimeo' */
81396
- './Vimeo-DKpnTiZ8.js'
81396
+ './Vimeo-DrDJ5O9H.js'
81397
81397
  ); }).then(function (n) { return n.Vimeo; }))
81398
81398
  },
81399
81399
  {
@@ -81402,7 +81402,7 @@ function requirePlayers () {
81402
81402
  canPlay: import_patterns.canPlay.mux,
81403
81403
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81404
81404
  /* webpackChunkName: 'reactPlayerMux' */
81405
- './Mux-Bgsc5vvM.js'
81405
+ './Mux-Cosy8sFO.js'
81406
81406
  ); }).then(function (n) { return n.Mux; }))
81407
81407
  },
81408
81408
  {
@@ -81411,7 +81411,7 @@ function requirePlayers () {
81411
81411
  canPlay: import_patterns.canPlay.facebook,
81412
81412
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81413
81413
  /* webpackChunkName: 'reactPlayerFacebook' */
81414
- './Facebook-DS0ye_bL.js'
81414
+ './Facebook-42iqQU2G.js'
81415
81415
  ); }).then(function (n) { return n.Facebook; }))
81416
81416
  },
81417
81417
  {
@@ -81420,7 +81420,7 @@ function requirePlayers () {
81420
81420
  canPlay: import_patterns.canPlay.streamable,
81421
81421
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81422
81422
  /* webpackChunkName: 'reactPlayerStreamable' */
81423
- './Streamable-BDhbB3m3.js'
81423
+ './Streamable-9anYiQtU.js'
81424
81424
  ); }).then(function (n) { return n.Streamable; }))
81425
81425
  },
81426
81426
  {
@@ -81429,7 +81429,7 @@ function requirePlayers () {
81429
81429
  canPlay: import_patterns.canPlay.wistia,
81430
81430
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81431
81431
  /* webpackChunkName: 'reactPlayerWistia' */
81432
- './Wistia-DKdMEz2a.js'
81432
+ './Wistia-fh9U2CA2.js'
81433
81433
  ); }).then(function (n) { return n.Wistia; }))
81434
81434
  },
81435
81435
  {
@@ -81438,7 +81438,7 @@ function requirePlayers () {
81438
81438
  canPlay: import_patterns.canPlay.twitch,
81439
81439
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81440
81440
  /* webpackChunkName: 'reactPlayerTwitch' */
81441
- './Twitch-ZG7WuoXD.js'
81441
+ './Twitch-Dud6e1Rv.js'
81442
81442
  ); }).then(function (n) { return n.Twitch; }))
81443
81443
  },
81444
81444
  {
@@ -81447,7 +81447,7 @@ function requirePlayers () {
81447
81447
  canPlay: import_patterns.canPlay.dailymotion,
81448
81448
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81449
81449
  /* webpackChunkName: 'reactPlayerDailyMotion' */
81450
- './DailyMotion-SZKPSpD1.js'
81450
+ './DailyMotion-B7yDPBbg.js'
81451
81451
  ); }).then(function (n) { return n.DailyMotion; }))
81452
81452
  },
81453
81453
  {
@@ -81456,7 +81456,7 @@ function requirePlayers () {
81456
81456
  canPlay: import_patterns.canPlay.mixcloud,
81457
81457
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81458
81458
  /* webpackChunkName: 'reactPlayerMixcloud' */
81459
- './Mixcloud-C1z9BVJ8.js'
81459
+ './Mixcloud-sBbcL5rG.js'
81460
81460
  ); }).then(function (n) { return n.Mixcloud; }))
81461
81461
  },
81462
81462
  {
@@ -81465,7 +81465,7 @@ function requirePlayers () {
81465
81465
  canPlay: import_patterns.canPlay.vidyard,
81466
81466
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81467
81467
  /* webpackChunkName: 'reactPlayerVidyard' */
81468
- './Vidyard-CkSCnLg5.js'
81468
+ './Vidyard-BuOu85uS.js'
81469
81469
  ); }).then(function (n) { return n.Vidyard; }))
81470
81470
  },
81471
81471
  {
@@ -81474,7 +81474,7 @@ function requirePlayers () {
81474
81474
  canPlay: import_patterns.canPlay.kaltura,
81475
81475
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81476
81476
  /* webpackChunkName: 'reactPlayerKaltura' */
81477
- './Kaltura-DAMolg_c.js'
81477
+ './Kaltura-Ct6kwbgP.js'
81478
81478
  ); }).then(function (n) { return n.Kaltura; }))
81479
81479
  },
81480
81480
  {
@@ -81486,7 +81486,7 @@ function requirePlayers () {
81486
81486
  },
81487
81487
  lazyPlayer: (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
81488
81488
  /* webpackChunkName: 'reactPlayerFilePlayer' */
81489
- './FilePlayer-B4_DDZXQ.js'
81489
+ './FilePlayer-CAnHK0Cd.js'
81490
81490
  ); }).then(function (n) { return n.FilePlayer; }))
81491
81491
  }
81492
81492
  ];
@@ -82307,7 +82307,7 @@ function requireReactPlayer () {
82307
82307
  var import_Player = __toESM(/*@__PURE__*/ requirePlayer());
82308
82308
  const Preview = (0, import_utils.lazy)(() => Promise.resolve().then(function () { return require(
82309
82309
  /* webpackChunkName: 'reactPlayerPreview' */
82310
- './Preview-CKXk6Axz.js'
82310
+ './Preview-DiVfo6aa.js'
82311
82311
  ); }).then(function (n) { return n.Preview; }));
82312
82312
  const IS_BROWSER = typeof window !== "undefined" && window.document && typeof document !== "undefined";
82313
82313
  const IS_GLOBAL = typeof commonjsGlobal !== "undefined" && commonjsGlobal.window && commonjsGlobal.window.document;
@@ -88758,6 +88758,247 @@ var useEventListener = function useEventListener(eventName, handler, element, sh
88758
88758
  }, [eventName, element, shouldRun]);
88759
88759
  };
88760
88760
 
88761
+ /**
88762
+ * Global Picture-in-Picture Manager
88763
+ * This module manages PiP state across component unmounts and route changes
88764
+ */
88765
+ var PictureInPictureManager = /** @class */function () {
88766
+ function PictureInPictureManager() {
88767
+ this.videoElement = null;
88768
+ this.pipContainer = null;
88769
+ this.currentVideoState = null;
88770
+ this.onStateChange = null;
88771
+ // Listen for PiP events globally
88772
+ document.addEventListener('leavepictureinpicture', this.handlePiPExit.bind(this));
88773
+ document.addEventListener('enterpictureinpicture', this.handlePiPEnter.bind(this));
88774
+ }
88775
+ /**
88776
+ * Register a video element for PiP management
88777
+ */
88778
+ PictureInPictureManager.prototype.registerVideo = function (videoElement, url, onStateChange) {
88779
+ this.videoElement = videoElement;
88780
+ this.onStateChange = onStateChange || null;
88781
+ // Store current video state
88782
+ this.currentVideoState = {
88783
+ url: url,
88784
+ currentTime: videoElement.currentTime,
88785
+ isPlaying: !videoElement.paused,
88786
+ volume: videoElement.volume,
88787
+ playbackRate: videoElement.playbackRate
88788
+ };
88789
+ // Add listeners to track state changes
88790
+ videoElement.addEventListener('timeupdate', this.handleTimeUpdate.bind(this));
88791
+ videoElement.addEventListener('play', this.handlePlayStateChange.bind(this));
88792
+ videoElement.addEventListener('pause', this.handlePlayStateChange.bind(this));
88793
+ videoElement.addEventListener('volumechange', this.handleVolumeChange.bind(this));
88794
+ videoElement.addEventListener('ratechange', this.handleRateChange.bind(this));
88795
+ };
88796
+ /**
88797
+ * Unregister the current video element
88798
+ */
88799
+ PictureInPictureManager.prototype.unregisterVideo = function () {
88800
+ if (this.videoElement) {
88801
+ this.videoElement.removeEventListener('timeupdate', this.handleTimeUpdate.bind(this));
88802
+ this.videoElement.removeEventListener('play', this.handlePlayStateChange.bind(this));
88803
+ this.videoElement.removeEventListener('pause', this.handlePlayStateChange.bind(this));
88804
+ this.videoElement.removeEventListener('volumechange', this.handleVolumeChange.bind(this));
88805
+ this.videoElement.removeEventListener('ratechange', this.handleRateChange.bind(this));
88806
+ }
88807
+ this.videoElement = null;
88808
+ this.onStateChange = null;
88809
+ };
88810
+ /**
88811
+ * Create a persistent video element for PiP
88812
+ */
88813
+ PictureInPictureManager.prototype.createPersistentVideo = function (originalVideo) {
88814
+ var persistentVideo = originalVideo.cloneNode(true);
88815
+ // Copy all relevant properties
88816
+ persistentVideo.src = originalVideo.src;
88817
+ persistentVideo.currentTime = originalVideo.currentTime;
88818
+ persistentVideo.volume = originalVideo.volume;
88819
+ persistentVideo.playbackRate = originalVideo.playbackRate;
88820
+ persistentVideo.muted = originalVideo.muted;
88821
+ // Set properties for PiP
88822
+ persistentVideo.style.position = 'fixed';
88823
+ persistentVideo.style.top = '-9999px';
88824
+ persistentVideo.style.left = '-9999px';
88825
+ persistentVideo.style.width = '1px';
88826
+ persistentVideo.style.height = '1px';
88827
+ persistentVideo.style.opacity = '0';
88828
+ persistentVideo.style.pointerEvents = 'none';
88829
+ return persistentVideo;
88830
+ };
88831
+ /**
88832
+ * Enter picture-in-picture mode with persistence
88833
+ */
88834
+ PictureInPictureManager.prototype.enterPiP = function () {
88835
+ return __awaiter(this, void 0, void 0, function () {
88836
+ var persistentVideo_1, error_1;
88837
+ return __generator(this, function (_a) {
88838
+ switch (_a.label) {
88839
+ case 0:
88840
+ if (!this.videoElement || !document.pictureInPictureEnabled) {
88841
+ return [2 /*return*/];
88842
+ }
88843
+ _a.label = 1;
88844
+ case 1:
88845
+ _a.trys.push([1, 6,, 7]);
88846
+ if (!document.pictureInPictureElement) return [3 /*break*/, 3];
88847
+ return [4 /*yield*/, document.exitPictureInPicture()];
88848
+ case 2:
88849
+ _a.sent();
88850
+ _a.label = 3;
88851
+ case 3:
88852
+ // Create a container if it doesn't exist
88853
+ if (!this.pipContainer) {
88854
+ this.pipContainer = document.createElement('div');
88855
+ this.pipContainer.id = 'suada-pip-container';
88856
+ this.pipContainer.style.position = 'fixed';
88857
+ this.pipContainer.style.top = '-9999px';
88858
+ this.pipContainer.style.left = '-9999px';
88859
+ this.pipContainer.style.width = '1px';
88860
+ this.pipContainer.style.height = '1px';
88861
+ this.pipContainer.style.zIndex = '-1';
88862
+ document.body.appendChild(this.pipContainer);
88863
+ }
88864
+ persistentVideo_1 = this.createPersistentVideo(this.videoElement);
88865
+ this.pipContainer.appendChild(persistentVideo_1);
88866
+ // Wait for video to load
88867
+ return [4 /*yield*/, new Promise(function (resolve) {
88868
+ if (persistentVideo_1.readyState >= 2) {
88869
+ resolve();
88870
+ } else {
88871
+ persistentVideo_1.addEventListener('loadedmetadata', function () {
88872
+ return resolve();
88873
+ }, {
88874
+ once: true
88875
+ });
88876
+ }
88877
+ })
88878
+ // Enter PiP mode
88879
+ ];
88880
+ case 4:
88881
+ // Wait for video to load
88882
+ _a.sent();
88883
+ // Enter PiP mode
88884
+ return [4 /*yield*/, persistentVideo_1.requestPictureInPicture()
88885
+ // Update the reference to the persistent video
88886
+ ];
88887
+ case 5:
88888
+ // Enter PiP mode
88889
+ _a.sent();
88890
+ // Update the reference to the persistent video
88891
+ this.videoElement = persistentVideo_1;
88892
+ return [3 /*break*/, 7];
88893
+ case 6:
88894
+ error_1 = _a.sent();
88895
+ console.error('Failed to enter picture-in-picture:', error_1);
88896
+ return [3 /*break*/, 7];
88897
+ case 7:
88898
+ return [2 /*return*/];
88899
+ }
88900
+ });
88901
+ });
88902
+ };
88903
+ /**
88904
+ * Exit picture-in-picture mode
88905
+ */
88906
+ PictureInPictureManager.prototype.exitPiP = function () {
88907
+ return __awaiter(this, void 0, void 0, function () {
88908
+ var error_2;
88909
+ return __generator(this, function (_a) {
88910
+ switch (_a.label) {
88911
+ case 0:
88912
+ _a.trys.push([0, 3,, 4]);
88913
+ if (!document.pictureInPictureElement) return [3 /*break*/, 2];
88914
+ return [4 /*yield*/, document.exitPictureInPicture()];
88915
+ case 1:
88916
+ _a.sent();
88917
+ _a.label = 2;
88918
+ case 2:
88919
+ return [3 /*break*/, 4];
88920
+ case 3:
88921
+ error_2 = _a.sent();
88922
+ console.error('Failed to exit picture-in-picture:', error_2);
88923
+ return [3 /*break*/, 4];
88924
+ case 4:
88925
+ return [2 /*return*/];
88926
+ }
88927
+ });
88928
+ });
88929
+ };
88930
+ /**
88931
+ * Check if currently in PiP mode
88932
+ */
88933
+ PictureInPictureManager.prototype.isPiPActive = function () {
88934
+ return !!document.pictureInPictureElement;
88935
+ };
88936
+ /**
88937
+ * Get current video state
88938
+ */
88939
+ PictureInPictureManager.prototype.getCurrentState = function () {
88940
+ return this.currentVideoState;
88941
+ };
88942
+ /**
88943
+ * Restore video state to a new video element
88944
+ */
88945
+ PictureInPictureManager.prototype.restoreStateToVideo = function (videoElement) {
88946
+ if (!this.currentVideoState) return;
88947
+ videoElement.currentTime = this.currentVideoState.currentTime;
88948
+ videoElement.volume = this.currentVideoState.volume;
88949
+ videoElement.playbackRate = this.currentVideoState.playbackRate;
88950
+ if (this.currentVideoState.isPlaying) {
88951
+ videoElement.play()["catch"](console.error);
88952
+ }
88953
+ };
88954
+ PictureInPictureManager.prototype.handleTimeUpdate = function () {
88955
+ if (this.videoElement && this.currentVideoState) {
88956
+ this.currentVideoState.currentTime = this.videoElement.currentTime;
88957
+ this.notifyStateChange();
88958
+ }
88959
+ };
88960
+ PictureInPictureManager.prototype.handlePlayStateChange = function () {
88961
+ if (this.videoElement && this.currentVideoState) {
88962
+ this.currentVideoState.isPlaying = !this.videoElement.paused;
88963
+ this.notifyStateChange();
88964
+ }
88965
+ };
88966
+ PictureInPictureManager.prototype.handleVolumeChange = function () {
88967
+ if (this.videoElement && this.currentVideoState) {
88968
+ this.currentVideoState.volume = this.videoElement.volume;
88969
+ this.notifyStateChange();
88970
+ }
88971
+ };
88972
+ PictureInPictureManager.prototype.handleRateChange = function () {
88973
+ if (this.videoElement && this.currentVideoState) {
88974
+ this.currentVideoState.playbackRate = this.videoElement.playbackRate;
88975
+ this.notifyStateChange();
88976
+ }
88977
+ };
88978
+ PictureInPictureManager.prototype.handlePiPEnter = function () {
88979
+ console.log('Entered picture-in-picture mode');
88980
+ };
88981
+ PictureInPictureManager.prototype.handlePiPExit = function () {
88982
+ console.log('Exited picture-in-picture mode');
88983
+ this.cleanup();
88984
+ };
88985
+ PictureInPictureManager.prototype.notifyStateChange = function () {
88986
+ if (this.onStateChange && this.currentVideoState) {
88987
+ this.onStateChange(this.currentVideoState);
88988
+ }
88989
+ };
88990
+ PictureInPictureManager.prototype.cleanup = function () {
88991
+ // Clean up the persistent container
88992
+ if (this.pipContainer && this.pipContainer.parentNode) {
88993
+ this.pipContainer.parentNode.removeChild(this.pipContainer);
88994
+ this.pipContainer = null;
88995
+ }
88996
+ };
88997
+ return PictureInPictureManager;
88998
+ }();
88999
+ // Create a singleton instance
89000
+ var pipManager = new PictureInPictureManager();
89001
+
88761
89002
  var count = 0;
88762
89003
  var defaultVideoState = {
88763
89004
  muted: false,
@@ -88842,6 +89083,8 @@ function usePlayerControls(_a) {
88842
89083
  };
88843
89084
  var handlePiPLeave = function handlePiPLeave() {
88844
89085
  setIsPiPActive(false);
89086
+ // Also cleanup the PiP manager when PiP exits
89087
+ pipManager.unregisterVideo();
88845
89088
  };
88846
89089
  document.addEventListener('fullscreenchange', handleFullscreenChange);
88847
89090
  document.addEventListener('enterpictureinpicture', handlePiPEnter);
@@ -88865,19 +89108,33 @@ function usePlayerControls(_a) {
88865
89108
  }, [url]); // Re-run when URL changes to ensure proper cleanup and setup
88866
89109
  React.useEffect(function () {
88867
89110
  setStartPlayed(false);
88868
- }, [url]);
89111
+ // Check if there's an active PiP session and restore state
89112
+ if (pipManager.isPiPActive()) {
89113
+ var savedState_1 = pipManager.getCurrentState();
89114
+ if (savedState_1 && savedState_1.url === url) {
89115
+ setIsPiPActive(true);
89116
+ // Restore video state from PiP manager
89117
+ setVideoState(function (prev) {
89118
+ var _a;
89119
+ return __assign(__assign({}, prev), {
89120
+ volume: savedState_1.volume,
89121
+ playbackRate: savedState_1.playbackRate,
89122
+ played: savedState_1.currentTime / (((_a = videoPlayerRef.current) === null || _a === void 0 ? void 0 : _a.getDuration()) || 1)
89123
+ });
89124
+ });
89125
+ setIsPlaying(savedState_1.isPlaying);
89126
+ }
89127
+ }
89128
+ }, [url, setIsPlaying]);
88869
89129
  // Cleanup effect to handle component unmounting while in PiP mode
88870
89130
  React.useEffect(function () {
88871
- var currentVideoPlayerRef = videoPlayerRef.current;
88872
89131
  return function () {
89132
+ // Unregister from PiP manager when component unmounts
89133
+ pipManager.unregisterVideo();
88873
89134
  // Check if we're in PiP mode when component unmounts
88874
89135
  if (document.pictureInPictureElement) {
88875
- // Try to keep the video element alive by cloning it
88876
- var videoElement = currentVideoPlayerRef === null || currentVideoPlayerRef === void 0 ? void 0 : currentVideoPlayerRef.getInternalPlayer();
88877
- if (videoElement && videoElement instanceof HTMLVideoElement) {
88878
- // Create a warning for the user that PiP will exit
88879
- console.log('Component unmounting while in Picture-in-Picture mode');
88880
- }
89136
+ // The PiP manager will handle keeping the video alive
89137
+ console.log('Component unmounting while in Picture-in-Picture mode - PiP will persist');
88881
89138
  }
88882
89139
  };
88883
89140
  }, []);
@@ -89051,9 +89308,18 @@ function usePlayerControls(_a) {
89051
89308
  if (videoPlayerRef.current && !startPlayed) {
89052
89309
  videoPlayerRef.current.seekTo(startTime);
89053
89310
  setStartPlayed(true);
89311
+ // Register video with PiP manager when it's ready
89312
+ var videoElement = videoPlayerRef.current.getInternalPlayer();
89313
+ if (videoElement && videoElement instanceof HTMLVideoElement) {
89314
+ // Restore state if there was a previous PiP session
89315
+ var savedState = pipManager.getCurrentState();
89316
+ if (savedState && savedState.url === url && pipManager.isPiPActive()) {
89317
+ pipManager.restoreStateToVideo(videoElement);
89318
+ }
89319
+ }
89054
89320
  }
89055
89321
  setLoading(false);
89056
- }, [startTime, startPlayed, setLoading]);
89322
+ }, [startTime, startPlayed, setLoading, url]);
89057
89323
  var handleFullScreen = function handleFullScreen() {
89058
89324
  var playerContainer = playerContainerRef.current;
89059
89325
  if (!playerContainer) {
@@ -89076,21 +89342,33 @@ function usePlayerControls(_a) {
89076
89342
  return;
89077
89343
  }
89078
89344
  if (document.pictureInPictureElement) {
89079
- document.exitPictureInPicture()["catch"](function (error) {
89345
+ pipManager.exitPiP()["catch"](function (error) {
89080
89346
  console.error('Failed to exit picture-in-picture:', error);
89081
89347
  });
89082
89348
  } else {
89349
+ // Register the video with the PiP manager
89350
+ pipManager.registerVideo(videoElement, url, function (state) {
89351
+ // Update local state when PiP video state changes
89352
+ setVideoState(function (prev) {
89353
+ return __assign(__assign({}, prev), {
89354
+ played: state.currentTime / duration,
89355
+ volume: state.volume,
89356
+ playbackRate: state.playbackRate
89357
+ });
89358
+ });
89359
+ setIsPlaying(state.isPlaying);
89360
+ });
89083
89361
  // Ensure the video is playing before entering PiP mode
89084
89362
  if (videoElement.paused && isPlaying) {
89085
89363
  videoElement.play().then(function () {
89086
- videoElement.requestPictureInPicture()["catch"](function (error) {
89364
+ pipManager.enterPiP()["catch"](function (error) {
89087
89365
  console.error('Failed to enter picture-in-picture:', error);
89088
89366
  });
89089
89367
  })["catch"](function (error) {
89090
89368
  console.error('Failed to play video before PiP:', error);
89091
89369
  });
89092
89370
  } else {
89093
- videoElement.requestPictureInPicture()["catch"](function (error) {
89371
+ pipManager.enterPiP()["catch"](function (error) {
89094
89372
  console.error('Failed to enter picture-in-picture:', error);
89095
89373
  });
89096
89374
  }
@@ -1,3 +1,3 @@
1
- export { A as AudioPlayer, k as Badge, h as Breadcrumb, B as Button, e as Checkbox, j as ColorPicker, o as ColumnNavigation, C as CourseCard, c as CustomSwitcher, m as CustomTooltip, d as DatePicker, u as DrawerTips, D as DropDown, G as GridActionMenu, L as Loader, N as NavigationBar, f as Pagination, P as PhoneCountryCode, R as RadioButton, v as RangeSlider, S as SearchInput, n as SplashScreen, p as StatusIndicator, s as TabNavigation, q as TabPanel, b as ThemeProvider, i as Tile, l as TooltipHeight, T as TranslationProvider, U as Uploader, V as VideoPlayer, t as activeTabClassName } from './index-BTR541gv.esm.js';
1
+ export { A as AudioPlayer, k as Badge, h as Breadcrumb, B as Button, e as Checkbox, j as ColorPicker, o as ColumnNavigation, C as CourseCard, c as CustomSwitcher, m as CustomTooltip, d as DatePicker, u as DrawerTips, D as DropDown, G as GridActionMenu, L as Loader, N as NavigationBar, f as Pagination, P as PhoneCountryCode, R as RadioButton, v as RangeSlider, S as SearchInput, n as SplashScreen, p as StatusIndicator, s as TabNavigation, q as TabPanel, b as ThemeProvider, i as Tile, l as TooltipHeight, T as TranslationProvider, U as Uploader, V as VideoPlayer, t as activeTabClassName } from './index-DKAGRUEW.esm.js';
2
2
  import 'react';
3
3
  import 'react-dom';
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Global Picture-in-Picture Manager
3
+ * This module manages PiP state across component unmounts and route changes
4
+ */
5
+ interface PiPVideoState {
6
+ url: string;
7
+ currentTime: number;
8
+ isPlaying: boolean;
9
+ volume: number;
10
+ playbackRate: number;
11
+ }
12
+ declare class PictureInPictureManager {
13
+ private videoElement;
14
+ private pipContainer;
15
+ private currentVideoState;
16
+ private onStateChange;
17
+ constructor();
18
+ /**
19
+ * Register a video element for PiP management
20
+ */
21
+ registerVideo(videoElement: HTMLVideoElement, url: string, onStateChange?: (state: PiPVideoState) => void): void;
22
+ /**
23
+ * Unregister the current video element
24
+ */
25
+ unregisterVideo(): void;
26
+ /**
27
+ * Create a persistent video element for PiP
28
+ */
29
+ private createPersistentVideo;
30
+ /**
31
+ * Enter picture-in-picture mode with persistence
32
+ */
33
+ enterPiP(): Promise<void>;
34
+ /**
35
+ * Exit picture-in-picture mode
36
+ */
37
+ exitPiP(): Promise<void>;
38
+ /**
39
+ * Check if currently in PiP mode
40
+ */
41
+ isPiPActive(): boolean;
42
+ /**
43
+ * Get current video state
44
+ */
45
+ getCurrentState(): PiPVideoState | null;
46
+ /**
47
+ * Restore video state to a new video element
48
+ */
49
+ restoreStateToVideo(videoElement: HTMLVideoElement): void;
50
+ private handleTimeUpdate;
51
+ private handlePlayStateChange;
52
+ private handleVolumeChange;
53
+ private handleRateChange;
54
+ private handlePiPEnter;
55
+ private handlePiPExit;
56
+ private notifyStateChange;
57
+ private cleanup;
58
+ }
59
+ export declare const pipManager: PictureInPictureManager;
60
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "suada-components",
3
3
  "private": false,
4
- "version": "1.8.0",
4
+ "version": "1.9.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.esm.js",