suada-components 1.9.0 → 1.10.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 (96) hide show
  1. package/dist/{components/DailyMotion-B7yDPBbg.js → DailyMotion-DacNkqsi.js} +1 -1
  2. package/dist/{components/DailyMotion-BmnymjR1.esm.js → DailyMotion-gaY-1HqX.esm.js} +1 -1
  3. package/dist/{components/Facebook-D9Ak6ZJU.esm.js → Facebook-C_tH1Bi_.esm.js} +1 -1
  4. package/dist/{components/Facebook-42iqQU2G.js → Facebook-D4wLMJkY.js} +1 -1
  5. package/dist/{components/FilePlayer-CAnHK0Cd.js → FilePlayer-B4s5OcYq.js} +1 -1
  6. package/dist/{components/FilePlayer-wg9lyafD.esm.js → FilePlayer-DqR2mvGK.esm.js} +1 -1
  7. package/dist/{components/Kaltura-DPaEN-dq.esm.js → Kaltura-C9QbmEfO.esm.js} +1 -1
  8. package/dist/{components/Kaltura-Ct6kwbgP.js → Kaltura-kCqUZWuf.js} +1 -1
  9. package/dist/{components/Mixcloud-sBbcL5rG.js → Mixcloud-2c71b3Nf.js} +1 -1
  10. package/dist/{components/Mixcloud-BobSN3YI.esm.js → Mixcloud-ib_DIXF1.esm.js} +1 -1
  11. package/dist/{components/Mux-Cosy8sFO.js → Mux-BsXgGo6C.js} +1 -1
  12. package/dist/{components/Mux-B9YP-rFr.esm.js → Mux-CJ6kEh1R.esm.js} +1 -1
  13. package/dist/{components/Preview-DiVfo6aa.js → Preview-gEkhA4mX.js} +1 -1
  14. package/dist/{components/Preview-XcTlhHT1.esm.js → Preview-kqr7fWet.esm.js} +1 -1
  15. package/dist/{components/SoundCloud-CIWqB-QW.js → SoundCloud-BWup2g--.js} +1 -1
  16. package/dist/{components/SoundCloud-BTHoyFWT.esm.js → SoundCloud-DJM0bsQG.esm.js} +1 -1
  17. package/dist/{components/Streamable-DsfQCy3p.esm.js → Streamable-CJltauTy.esm.js} +1 -1
  18. package/dist/{components/Streamable-9anYiQtU.js → Streamable-UeTHV2nZ.js} +1 -1
  19. package/dist/{components/Twitch-D1BOr8hj.esm.js → Twitch-C9qq_89Q.esm.js} +1 -1
  20. package/dist/{components/Twitch-Dud6e1Rv.js → Twitch-_N8mEsiS.js} +1 -1
  21. package/dist/{components/Vidyard-BuOu85uS.js → Vidyard-CQuxB99Z.js} +1 -1
  22. package/dist/{components/Vidyard-C1csjpQH.esm.js → Vidyard-gtcLQdYd.esm.js} +1 -1
  23. package/dist/{components/Vimeo-CHlHIswX.esm.js → Vimeo-Dzp5eoLi.esm.js} +1 -1
  24. package/dist/{components/Vimeo-DrDJ5O9H.js → Vimeo-nhXVoFTb.js} +1 -1
  25. package/dist/{components/Wistia-fh9U2CA2.js → Wistia-C1DqA9IW.js} +1 -1
  26. package/dist/{components/Wistia-D-eYyONb.esm.js → Wistia-DV3BO3z9.esm.js} +1 -1
  27. package/dist/{components/YouTube-CmnnzZvk.esm.js → YouTube-BKwvJCnt.esm.js} +1 -1
  28. package/dist/{components/YouTube-DC2uZ14c.js → YouTube-DDou5phH.js} +1 -1
  29. package/dist/components/CourseCard/CourseCard.styles.d.ts +1 -1
  30. package/dist/components/DailyMotion-B8IJNjSc.js +180 -0
  31. package/dist/components/DailyMotion-COg3zgIZ.esm.js +178 -0
  32. package/dist/components/Facebook-DJ7a3Bj8.js +181 -0
  33. package/dist/components/Facebook-NS80Vk6j.esm.js +179 -0
  34. package/dist/components/FilePlayer-D-fc3B0E.esm.js +408 -0
  35. package/dist/components/FilePlayer-SyLt5qGX.js +410 -0
  36. package/dist/components/Kaltura-BTFxSMxP.js +178 -0
  37. package/dist/components/Kaltura-CmFIWSef.esm.js +176 -0
  38. package/dist/components/Mixcloud-CO5MsWUJ.esm.js +164 -0
  39. package/dist/components/Mixcloud-DHAfVpcc.js +166 -0
  40. package/dist/components/Mux-C8-HithD.esm.js +264 -0
  41. package/dist/components/Mux-bycDxP8G.js +266 -0
  42. package/dist/components/Preview-Clg3y6sj.esm.js +173 -0
  43. package/dist/components/Preview-CzpcknZI.js +175 -0
  44. package/dist/components/SoundCloud-Dz9DeIIM.js +183 -0
  45. package/dist/components/SoundCloud-LfWEBVy1.esm.js +181 -0
  46. package/dist/components/Streamable-BpcVhi4M.esm.js +174 -0
  47. package/dist/components/Streamable-Cs_c-7jS.js +176 -0
  48. package/dist/components/Twitch-BJ9aSIM2.esm.js +168 -0
  49. package/dist/components/Twitch-C9bksXF6.js +170 -0
  50. package/dist/components/VideoPlayer/PiPContext.d.ts +8 -0
  51. package/dist/components/VideoPlayer/PiPContext.js +149 -0
  52. package/dist/components/VideoPlayer/PiPContext.js.map +1 -0
  53. package/dist/components/VideoPlayer/PiPContext.types.d.ts +16 -0
  54. package/dist/components/VideoPlayer/PiPContext.types.js +2 -0
  55. package/dist/components/VideoPlayer/PiPContext.types.js.map +1 -0
  56. package/dist/components/VideoPlayer/usePiP.d.ts +2 -0
  57. package/dist/components/VideoPlayer/usePiP.js +10 -0
  58. package/dist/components/VideoPlayer/usePiP.js.map +1 -0
  59. package/dist/components/VideoPlayer/usePlayerControls.js +46 -64
  60. package/dist/components/VideoPlayer/usePlayerControls.js.map +1 -1
  61. package/dist/components/Vidyard-CsUFSBXh.js +174 -0
  62. package/dist/components/Vidyard-Dc8NHJ7p.esm.js +172 -0
  63. package/dist/components/Vimeo-CwlScNtK.esm.js +213 -0
  64. package/dist/components/Vimeo-D6C93592.js +215 -0
  65. package/dist/components/Wistia-Bxvdn3oO.js +190 -0
  66. package/dist/components/Wistia-Cwl4fNWW.esm.js +188 -0
  67. package/dist/components/YouTube-BF85SRPF.js +260 -0
  68. package/dist/components/YouTube-DKkYzN7-.esm.js +258 -0
  69. package/dist/components/components/CourseCard/CourseCard.styles.d.ts +1 -1
  70. package/dist/components/components/VideoPlayer/PiPContext.d.ts +8 -0
  71. package/dist/components/components/VideoPlayer/PiPContext.types.d.ts +16 -0
  72. package/dist/components/components/VideoPlayer/usePiP.d.ts +2 -0
  73. package/dist/components/components/index.d.ts +2 -0
  74. package/dist/components/{index-DetZ05pw.js → index-C08W0lXg.js} +157 -295
  75. package/dist/components/{index-DKAGRUEW.esm.js → index-F6zEoSWf.esm.js} +156 -296
  76. package/dist/components/index.d.ts +2 -0
  77. package/dist/components/index.esm.js +1 -1
  78. package/dist/components/index.js +2 -0
  79. package/dist/components/index.js.map +1 -1
  80. package/dist/icons/components/CourseCard/CourseCard.styles.d.ts +1 -1
  81. package/dist/icons/components/VideoPlayer/PiPContext.d.ts +8 -0
  82. package/dist/icons/components/VideoPlayer/PiPContext.types.d.ts +16 -0
  83. package/dist/icons/components/VideoPlayer/usePiP.d.ts +2 -0
  84. package/dist/icons/components/index.d.ts +2 -0
  85. package/dist/index-CcTTuhg8.esm.js +94920 -0
  86. package/dist/index-Dq4qpx9F.js +95142 -0
  87. package/dist/index.d.ts +2 -0
  88. package/dist/index.esm.js +3 -3
  89. package/dist/index.js +3 -0
  90. package/dist/index.js.map +1 -1
  91. package/package.json +1 -1
  92. package/dist/components/VideoPlayer/pipManager.d.ts +0 -60
  93. package/dist/components/VideoPlayer/pipManager.js +0 -272
  94. package/dist/components/VideoPlayer/pipManager.js.map +0 -1
  95. package/dist/components/components/VideoPlayer/pipManager.d.ts +0 -60
  96. package/dist/icons/components/VideoPlayer/pipManager.d.ts +0 -60
@@ -81355,7 +81355,7 @@ function requirePlayers () {
81355
81355
  canPlay: import_patterns.canPlay.youtube,
81356
81356
  lazyPlayer: (0, import_utils.lazy)(() => import(
81357
81357
  /* webpackChunkName: 'reactPlayerYouTube' */
81358
- './YouTube-CmnnzZvk.esm.js'
81358
+ './YouTube-DKkYzN7-.esm.js'
81359
81359
  ).then(function (n) { return n.Y; }))
81360
81360
  },
81361
81361
  {
@@ -81364,7 +81364,7 @@ function requirePlayers () {
81364
81364
  canPlay: import_patterns.canPlay.soundcloud,
81365
81365
  lazyPlayer: (0, import_utils.lazy)(() => import(
81366
81366
  /* webpackChunkName: 'reactPlayerSoundCloud' */
81367
- './SoundCloud-BTHoyFWT.esm.js'
81367
+ './SoundCloud-LfWEBVy1.esm.js'
81368
81368
  ).then(function (n) { return n.S; }))
81369
81369
  },
81370
81370
  {
@@ -81373,7 +81373,7 @@ function requirePlayers () {
81373
81373
  canPlay: import_patterns.canPlay.vimeo,
81374
81374
  lazyPlayer: (0, import_utils.lazy)(() => import(
81375
81375
  /* webpackChunkName: 'reactPlayerVimeo' */
81376
- './Vimeo-CHlHIswX.esm.js'
81376
+ './Vimeo-CwlScNtK.esm.js'
81377
81377
  ).then(function (n) { return n.V; }))
81378
81378
  },
81379
81379
  {
@@ -81382,7 +81382,7 @@ function requirePlayers () {
81382
81382
  canPlay: import_patterns.canPlay.mux,
81383
81383
  lazyPlayer: (0, import_utils.lazy)(() => import(
81384
81384
  /* webpackChunkName: 'reactPlayerMux' */
81385
- './Mux-B9YP-rFr.esm.js'
81385
+ './Mux-C8-HithD.esm.js'
81386
81386
  ).then(function (n) { return n.M; }))
81387
81387
  },
81388
81388
  {
@@ -81391,7 +81391,7 @@ function requirePlayers () {
81391
81391
  canPlay: import_patterns.canPlay.facebook,
81392
81392
  lazyPlayer: (0, import_utils.lazy)(() => import(
81393
81393
  /* webpackChunkName: 'reactPlayerFacebook' */
81394
- './Facebook-D9Ak6ZJU.esm.js'
81394
+ './Facebook-NS80Vk6j.esm.js'
81395
81395
  ).then(function (n) { return n.F; }))
81396
81396
  },
81397
81397
  {
@@ -81400,7 +81400,7 @@ function requirePlayers () {
81400
81400
  canPlay: import_patterns.canPlay.streamable,
81401
81401
  lazyPlayer: (0, import_utils.lazy)(() => import(
81402
81402
  /* webpackChunkName: 'reactPlayerStreamable' */
81403
- './Streamable-DsfQCy3p.esm.js'
81403
+ './Streamable-BpcVhi4M.esm.js'
81404
81404
  ).then(function (n) { return n.S; }))
81405
81405
  },
81406
81406
  {
@@ -81409,7 +81409,7 @@ function requirePlayers () {
81409
81409
  canPlay: import_patterns.canPlay.wistia,
81410
81410
  lazyPlayer: (0, import_utils.lazy)(() => import(
81411
81411
  /* webpackChunkName: 'reactPlayerWistia' */
81412
- './Wistia-D-eYyONb.esm.js'
81412
+ './Wistia-Cwl4fNWW.esm.js'
81413
81413
  ).then(function (n) { return n.W; }))
81414
81414
  },
81415
81415
  {
@@ -81418,7 +81418,7 @@ function requirePlayers () {
81418
81418
  canPlay: import_patterns.canPlay.twitch,
81419
81419
  lazyPlayer: (0, import_utils.lazy)(() => import(
81420
81420
  /* webpackChunkName: 'reactPlayerTwitch' */
81421
- './Twitch-D1BOr8hj.esm.js'
81421
+ './Twitch-BJ9aSIM2.esm.js'
81422
81422
  ).then(function (n) { return n.T; }))
81423
81423
  },
81424
81424
  {
@@ -81427,7 +81427,7 @@ function requirePlayers () {
81427
81427
  canPlay: import_patterns.canPlay.dailymotion,
81428
81428
  lazyPlayer: (0, import_utils.lazy)(() => import(
81429
81429
  /* webpackChunkName: 'reactPlayerDailyMotion' */
81430
- './DailyMotion-BmnymjR1.esm.js'
81430
+ './DailyMotion-COg3zgIZ.esm.js'
81431
81431
  ).then(function (n) { return n.D; }))
81432
81432
  },
81433
81433
  {
@@ -81436,7 +81436,7 @@ function requirePlayers () {
81436
81436
  canPlay: import_patterns.canPlay.mixcloud,
81437
81437
  lazyPlayer: (0, import_utils.lazy)(() => import(
81438
81438
  /* webpackChunkName: 'reactPlayerMixcloud' */
81439
- './Mixcloud-BobSN3YI.esm.js'
81439
+ './Mixcloud-CO5MsWUJ.esm.js'
81440
81440
  ).then(function (n) { return n.M; }))
81441
81441
  },
81442
81442
  {
@@ -81445,7 +81445,7 @@ function requirePlayers () {
81445
81445
  canPlay: import_patterns.canPlay.vidyard,
81446
81446
  lazyPlayer: (0, import_utils.lazy)(() => import(
81447
81447
  /* webpackChunkName: 'reactPlayerVidyard' */
81448
- './Vidyard-C1csjpQH.esm.js'
81448
+ './Vidyard-Dc8NHJ7p.esm.js'
81449
81449
  ).then(function (n) { return n.V; }))
81450
81450
  },
81451
81451
  {
@@ -81454,7 +81454,7 @@ function requirePlayers () {
81454
81454
  canPlay: import_patterns.canPlay.kaltura,
81455
81455
  lazyPlayer: (0, import_utils.lazy)(() => import(
81456
81456
  /* webpackChunkName: 'reactPlayerKaltura' */
81457
- './Kaltura-DPaEN-dq.esm.js'
81457
+ './Kaltura-CmFIWSef.esm.js'
81458
81458
  ).then(function (n) { return n.K; }))
81459
81459
  },
81460
81460
  {
@@ -81466,7 +81466,7 @@ function requirePlayers () {
81466
81466
  },
81467
81467
  lazyPlayer: (0, import_utils.lazy)(() => import(
81468
81468
  /* webpackChunkName: 'reactPlayerFilePlayer' */
81469
- './FilePlayer-wg9lyafD.esm.js'
81469
+ './FilePlayer-D-fc3B0E.esm.js'
81470
81470
  ).then(function (n) { return n.F; }))
81471
81471
  }
81472
81472
  ];
@@ -82287,7 +82287,7 @@ function requireReactPlayer () {
82287
82287
  var import_Player = __toESM(/*@__PURE__*/ requirePlayer());
82288
82288
  const Preview = (0, import_utils.lazy)(() => import(
82289
82289
  /* webpackChunkName: 'reactPlayerPreview' */
82290
- './Preview-XcTlhHT1.esm.js'
82290
+ './Preview-Clg3y6sj.esm.js'
82291
82291
  ).then(function (n) { return n.P; }));
82292
82292
  const IS_BROWSER = typeof window !== "undefined" && window.document && typeof document !== "undefined";
82293
82293
  const IS_GLOBAL = typeof commonjsGlobal !== "undefined" && commonjsGlobal.window && commonjsGlobal.window.document;
@@ -88738,153 +88738,69 @@ var useEventListener = function useEventListener(eventName, handler, element, sh
88738
88738
  }, [eventName, element, shouldRun]);
88739
88739
  };
88740
88740
 
88741
- /**
88742
- * Global Picture-in-Picture Manager
88743
- * This module manages PiP state across component unmounts and route changes
88744
- */
88745
- var PictureInPictureManager = /** @class */function () {
88746
- function PictureInPictureManager() {
88747
- this.videoElement = null;
88748
- this.pipContainer = null;
88749
- this.currentVideoState = null;
88750
- this.onStateChange = null;
88751
- // Listen for PiP events globally
88752
- document.addEventListener('leavepictureinpicture', this.handlePiPExit.bind(this));
88753
- document.addEventListener('enterpictureinpicture', this.handlePiPEnter.bind(this));
88754
- }
88755
- /**
88756
- * Register a video element for PiP management
88757
- */
88758
- PictureInPictureManager.prototype.registerVideo = function (videoElement, url, onStateChange) {
88759
- this.videoElement = videoElement;
88760
- this.onStateChange = onStateChange || null;
88761
- // Store current video state
88762
- this.currentVideoState = {
88763
- url: url,
88764
- currentTime: videoElement.currentTime,
88765
- isPlaying: !videoElement.paused,
88766
- volume: videoElement.volume,
88767
- playbackRate: videoElement.playbackRate
88768
- };
88769
- // Add listeners to track state changes
88770
- videoElement.addEventListener('timeupdate', this.handleTimeUpdate.bind(this));
88771
- videoElement.addEventListener('play', this.handlePlayStateChange.bind(this));
88772
- videoElement.addEventListener('pause', this.handlePlayStateChange.bind(this));
88773
- videoElement.addEventListener('volumechange', this.handleVolumeChange.bind(this));
88774
- videoElement.addEventListener('ratechange', this.handleRateChange.bind(this));
88775
- };
88776
- /**
88777
- * Unregister the current video element
88778
- */
88779
- PictureInPictureManager.prototype.unregisterVideo = function () {
88780
- if (this.videoElement) {
88781
- this.videoElement.removeEventListener('timeupdate', this.handleTimeUpdate.bind(this));
88782
- this.videoElement.removeEventListener('play', this.handlePlayStateChange.bind(this));
88783
- this.videoElement.removeEventListener('pause', this.handlePlayStateChange.bind(this));
88784
- this.videoElement.removeEventListener('volumechange', this.handleVolumeChange.bind(this));
88785
- this.videoElement.removeEventListener('ratechange', this.handleRateChange.bind(this));
88786
- }
88787
- this.videoElement = null;
88788
- this.onStateChange = null;
88789
- };
88790
- /**
88791
- * Create a persistent video element for PiP
88792
- */
88793
- PictureInPictureManager.prototype.createPersistentVideo = function (originalVideo) {
88794
- var persistentVideo = originalVideo.cloneNode(true);
88795
- // Copy all relevant properties
88796
- persistentVideo.src = originalVideo.src;
88797
- persistentVideo.currentTime = originalVideo.currentTime;
88798
- persistentVideo.volume = originalVideo.volume;
88799
- persistentVideo.playbackRate = originalVideo.playbackRate;
88800
- persistentVideo.muted = originalVideo.muted;
88801
- // Set properties for PiP
88802
- persistentVideo.style.position = 'fixed';
88803
- persistentVideo.style.top = '-9999px';
88804
- persistentVideo.style.left = '-9999px';
88805
- persistentVideo.style.width = '1px';
88806
- persistentVideo.style.height = '1px';
88807
- persistentVideo.style.opacity = '0';
88808
- persistentVideo.style.pointerEvents = 'none';
88809
- return persistentVideo;
88810
- };
88811
- /**
88812
- * Enter picture-in-picture mode with persistence
88813
- */
88814
- PictureInPictureManager.prototype.enterPiP = function () {
88815
- return __awaiter(this, void 0, void 0, function () {
88816
- var persistentVideo_1, error_1;
88741
+ var PiPContext = /*#__PURE__*/createContext(undefined);
88742
+ var PiPProvider = function PiPProvider(_a) {
88743
+ var children = _a.children;
88744
+ var _b = useState(false),
88745
+ isPiPActive = _b[0],
88746
+ setIsPiPActive = _b[1];
88747
+ var _c = useState(null),
88748
+ pipVideoState = _c[0],
88749
+ setPipVideoState = _c[1];
88750
+ var videoElementRef = useRef(null);
88751
+ var updateVideoState = useCallback(function (state) {
88752
+ setPipVideoState(function (prev) {
88753
+ return prev ? __assign(__assign({}, prev), state) : null;
88754
+ });
88755
+ }, []);
88756
+ var registerVideoElement = useCallback(function (element) {
88757
+ videoElementRef.current = element;
88758
+ }, []);
88759
+ var unregisterVideoElement = useCallback(function () {
88760
+ videoElementRef.current = null;
88761
+ }, []);
88762
+ var enterPiP = useCallback(function (videoElement, videoState) {
88763
+ return __awaiter(void 0, void 0, void 0, function () {
88764
+ var error_1;
88817
88765
  return __generator(this, function (_a) {
88818
88766
  switch (_a.label) {
88819
88767
  case 0:
88820
- if (!this.videoElement || !document.pictureInPictureEnabled) {
88821
- return [2 /*return*/];
88768
+ if (!document.pictureInPictureEnabled) {
88769
+ console.warn('Picture-in-Picture is not supported in this browser');
88770
+ return [2 /*return*/, false];
88771
+ }
88772
+ if (document.pictureInPictureElement) {
88773
+ console.warn('Another video is already in Picture-in-Picture mode');
88774
+ return [2 /*return*/, false];
88822
88775
  }
88823
88776
  _a.label = 1;
88824
88777
  case 1:
88825
- _a.trys.push([1, 6,, 7]);
88826
- if (!document.pictureInPictureElement) return [3 /*break*/, 3];
88827
- return [4 /*yield*/, document.exitPictureInPicture()];
88778
+ _a.trys.push([1, 5,, 6]);
88779
+ // Store video state
88780
+ setPipVideoState(videoState);
88781
+ videoElementRef.current = videoElement;
88782
+ if (!(videoElement.paused && videoState.isPlaying)) return [3 /*break*/, 3];
88783
+ return [4 /*yield*/, videoElement.play()];
88828
88784
  case 2:
88829
88785
  _a.sent();
88830
88786
  _a.label = 3;
88831
88787
  case 3:
88832
- // Create a container if it doesn't exist
88833
- if (!this.pipContainer) {
88834
- this.pipContainer = document.createElement('div');
88835
- this.pipContainer.id = 'suada-pip-container';
88836
- this.pipContainer.style.position = 'fixed';
88837
- this.pipContainer.style.top = '-9999px';
88838
- this.pipContainer.style.left = '-9999px';
88839
- this.pipContainer.style.width = '1px';
88840
- this.pipContainer.style.height = '1px';
88841
- this.pipContainer.style.zIndex = '-1';
88842
- document.body.appendChild(this.pipContainer);
88843
- }
88844
- persistentVideo_1 = this.createPersistentVideo(this.videoElement);
88845
- this.pipContainer.appendChild(persistentVideo_1);
88846
- // Wait for video to load
88847
- return [4 /*yield*/, new Promise(function (resolve) {
88848
- if (persistentVideo_1.readyState >= 2) {
88849
- resolve();
88850
- } else {
88851
- persistentVideo_1.addEventListener('loadedmetadata', function () {
88852
- return resolve();
88853
- }, {
88854
- once: true
88855
- });
88856
- }
88857
- })
88858
- // Enter PiP mode
88859
- ];
88788
+ return [4 /*yield*/, videoElement.requestPictureInPicture()];
88860
88789
  case 4:
88861
- // Wait for video to load
88862
88790
  _a.sent();
88863
- // Enter PiP mode
88864
- return [4 /*yield*/, persistentVideo_1.requestPictureInPicture()
88865
- // Update the reference to the persistent video
88866
- ];
88791
+ return [2 /*return*/, true];
88867
88792
  case 5:
88868
- // Enter PiP mode
88869
- _a.sent();
88870
- // Update the reference to the persistent video
88871
- this.videoElement = persistentVideo_1;
88872
- return [3 /*break*/, 7];
88873
- case 6:
88874
88793
  error_1 = _a.sent();
88875
88794
  console.error('Failed to enter picture-in-picture:', error_1);
88876
- return [3 /*break*/, 7];
88877
- case 7:
88795
+ return [2 /*return*/, false];
88796
+ case 6:
88878
88797
  return [2 /*return*/];
88879
88798
  }
88880
88799
  });
88881
88800
  });
88882
- };
88883
- /**
88884
- * Exit picture-in-picture mode
88885
- */
88886
- PictureInPictureManager.prototype.exitPiP = function () {
88887
- return __awaiter(this, void 0, void 0, function () {
88801
+ }, []);
88802
+ var exitPiP = useCallback(function () {
88803
+ return __awaiter(void 0, void 0, void 0, function () {
88888
88804
  var error_2;
88889
88805
  return __generator(this, function (_a) {
88890
88806
  switch (_a.label) {
@@ -88896,88 +88812,56 @@ var PictureInPictureManager = /** @class */function () {
88896
88812
  _a.sent();
88897
88813
  _a.label = 2;
88898
88814
  case 2:
88899
- return [3 /*break*/, 4];
88815
+ return [2 /*return*/, true];
88900
88816
  case 3:
88901
88817
  error_2 = _a.sent();
88902
88818
  console.error('Failed to exit picture-in-picture:', error_2);
88903
- return [3 /*break*/, 4];
88819
+ return [2 /*return*/, false];
88904
88820
  case 4:
88905
88821
  return [2 /*return*/];
88906
88822
  }
88907
88823
  });
88908
88824
  });
88825
+ }, []);
88826
+ // Listen for PiP events
88827
+ useEffect(function () {
88828
+ var handlePiPEnter = function handlePiPEnter() {
88829
+ setIsPiPActive(true);
88830
+ };
88831
+ var handlePiPLeave = function handlePiPLeave() {
88832
+ setIsPiPActive(false);
88833
+ // Keep the video state for potential restoration
88834
+ // but don't clear it immediately
88835
+ };
88836
+ document.addEventListener('enterpictureinpicture', handlePiPEnter);
88837
+ document.addEventListener('leavepictureinpicture', handlePiPLeave);
88838
+ return function () {
88839
+ document.removeEventListener('enterpictureinpicture', handlePiPEnter);
88840
+ document.removeEventListener('leavepictureinpicture', handlePiPLeave);
88841
+ };
88842
+ }, []);
88843
+ var value = {
88844
+ isPiPActive: isPiPActive,
88845
+ pipVideoState: pipVideoState,
88846
+ enterPiP: enterPiP,
88847
+ exitPiP: exitPiP,
88848
+ updateVideoState: updateVideoState,
88849
+ registerVideoElement: registerVideoElement,
88850
+ unregisterVideoElement: unregisterVideoElement
88909
88851
  };
88910
- /**
88911
- * Check if currently in PiP mode
88912
- */
88913
- PictureInPictureManager.prototype.isPiPActive = function () {
88914
- return !!document.pictureInPictureElement;
88915
- };
88916
- /**
88917
- * Get current video state
88918
- */
88919
- PictureInPictureManager.prototype.getCurrentState = function () {
88920
- return this.currentVideoState;
88921
- };
88922
- /**
88923
- * Restore video state to a new video element
88924
- */
88925
- PictureInPictureManager.prototype.restoreStateToVideo = function (videoElement) {
88926
- if (!this.currentVideoState) return;
88927
- videoElement.currentTime = this.currentVideoState.currentTime;
88928
- videoElement.volume = this.currentVideoState.volume;
88929
- videoElement.playbackRate = this.currentVideoState.playbackRate;
88930
- if (this.currentVideoState.isPlaying) {
88931
- videoElement.play()["catch"](console.error);
88932
- }
88933
- };
88934
- PictureInPictureManager.prototype.handleTimeUpdate = function () {
88935
- if (this.videoElement && this.currentVideoState) {
88936
- this.currentVideoState.currentTime = this.videoElement.currentTime;
88937
- this.notifyStateChange();
88938
- }
88939
- };
88940
- PictureInPictureManager.prototype.handlePlayStateChange = function () {
88941
- if (this.videoElement && this.currentVideoState) {
88942
- this.currentVideoState.isPlaying = !this.videoElement.paused;
88943
- this.notifyStateChange();
88944
- }
88945
- };
88946
- PictureInPictureManager.prototype.handleVolumeChange = function () {
88947
- if (this.videoElement && this.currentVideoState) {
88948
- this.currentVideoState.volume = this.videoElement.volume;
88949
- this.notifyStateChange();
88950
- }
88951
- };
88952
- PictureInPictureManager.prototype.handleRateChange = function () {
88953
- if (this.videoElement && this.currentVideoState) {
88954
- this.currentVideoState.playbackRate = this.videoElement.playbackRate;
88955
- this.notifyStateChange();
88956
- }
88957
- };
88958
- PictureInPictureManager.prototype.handlePiPEnter = function () {
88959
- console.log('Entered picture-in-picture mode');
88960
- };
88961
- PictureInPictureManager.prototype.handlePiPExit = function () {
88962
- console.log('Exited picture-in-picture mode');
88963
- this.cleanup();
88964
- };
88965
- PictureInPictureManager.prototype.notifyStateChange = function () {
88966
- if (this.onStateChange && this.currentVideoState) {
88967
- this.onStateChange(this.currentVideoState);
88968
- }
88969
- };
88970
- PictureInPictureManager.prototype.cleanup = function () {
88971
- // Clean up the persistent container
88972
- if (this.pipContainer && this.pipContainer.parentNode) {
88973
- this.pipContainer.parentNode.removeChild(this.pipContainer);
88974
- this.pipContainer = null;
88975
- }
88976
- };
88977
- return PictureInPictureManager;
88978
- }();
88979
- // Create a singleton instance
88980
- var pipManager = new PictureInPictureManager();
88852
+ return jsxRuntimeExports.jsx(PiPContext.Provider, {
88853
+ value: value,
88854
+ children: children
88855
+ });
88856
+ };
88857
+
88858
+ var usePiP = function usePiP() {
88859
+ var context = useContext(PiPContext);
88860
+ if (context === undefined) {
88861
+ throw new Error('usePiP must be used within a PiPProvider');
88862
+ }
88863
+ return context;
88864
+ };
88981
88865
 
88982
88866
  var count = 0;
88983
88867
  var defaultVideoState = {
@@ -89010,26 +88894,30 @@ function usePlayerControls(_a) {
89010
88894
  isSubtitlesChecked = _e[0],
89011
88895
  setIsSubtitlesChecked = _e[1];
89012
88896
  var _f = useState(false),
89013
- isPiPActive = _f[0],
89014
- setIsPiPActive = _f[1];
88897
+ isFullscreen = _f[0],
88898
+ setIsFullscreen = _f[1];
89015
88899
  var _g = useState(false),
89016
- isFullscreen = _g[0],
89017
- setIsFullscreen = _g[1];
89018
- var _h = useState(false),
89019
- isControlsActive = _h[0],
89020
- setIsControlsActive = _h[1];
88900
+ isControlsActive = _g[0],
88901
+ setIsControlsActive = _g[1];
89021
88902
  var videoPlayerRef = useRef(null);
89022
88903
  var controlRef = useRef(null);
89023
88904
  var playerContainerRef = useRef(null);
89024
- var _j = useState([]),
89025
- subtitles = _j[0],
89026
- setSubtitles = _j[1];
89027
- var _k = useState(''),
89028
- currentSubtitle = _k[0],
89029
- setCurrentSubtitle = _k[1];
88905
+ var _h = useState([]),
88906
+ subtitles = _h[0],
88907
+ setSubtitles = _h[1];
88908
+ var _j = useState(''),
88909
+ currentSubtitle = _j[0],
88910
+ setCurrentSubtitle = _j[1];
89030
88911
  var lastSubtitleIndexRef = useRef(null);
89031
88912
  var lastPlaybackTimeRef = useRef(0);
89032
88913
  var lastCallTimeRef = useRef(Date.now());
88914
+ // Use PiP context instead of local state
88915
+ var _k = usePiP(),
88916
+ isPiPActive = _k.isPiPActive,
88917
+ enterPiP = _k.enterPiP,
88918
+ exitPiP = _k.exitPiP,
88919
+ registerVideoElement = _k.registerVideoElement,
88920
+ unregisterVideoElement = _k.unregisterVideoElement;
89033
88921
  var muted = videoState.muted,
89034
88922
  volume = videoState.volume,
89035
88923
  prevVolume = videoState.prevVolume,
@@ -89059,12 +88947,21 @@ function usePlayerControls(_a) {
89059
88947
  setIsFullscreen(!!document.fullscreenElement);
89060
88948
  };
89061
88949
  var handlePiPEnter = function handlePiPEnter() {
89062
- setIsPiPActive(true);
88950
+ var _a;
88951
+ // Use context method to update global PiP state
88952
+ var videoElement = (_a = videoPlayerRef.current) === null || _a === void 0 ? void 0 : _a.getInternalPlayer();
88953
+ if (videoElement && videoElement instanceof HTMLVideoElement) {
88954
+ enterPiP(videoElement, {
88955
+ url: url,
88956
+ currentTime: videoElement.currentTime,
88957
+ isPlaying: isPlaying,
88958
+ volume: videoState.volume,
88959
+ muted: videoState.muted
88960
+ });
88961
+ }
89063
88962
  };
89064
88963
  var handlePiPLeave = function handlePiPLeave() {
89065
- setIsPiPActive(false);
89066
- // Also cleanup the PiP manager when PiP exits
89067
- pipManager.unregisterVideo();
88964
+ exitPiP();
89068
88965
  };
89069
88966
  document.addEventListener('fullscreenchange', handleFullscreenChange);
89070
88967
  document.addEventListener('enterpictureinpicture', handlePiPEnter);
@@ -89074,6 +88971,8 @@ function usePlayerControls(_a) {
89074
88971
  if (videoElement && videoElement instanceof HTMLVideoElement) {
89075
88972
  videoElement.addEventListener('enterpictureinpicture', handlePiPEnter);
89076
88973
  videoElement.addEventListener('leavepictureinpicture', handlePiPLeave);
88974
+ // Register video element with PiP context
88975
+ registerVideoElement(videoElement);
89077
88976
  }
89078
88977
  return function () {
89079
88978
  document.removeEventListener('fullscreenchange', handleFullscreenChange);
@@ -89084,37 +88983,25 @@ function usePlayerControls(_a) {
89084
88983
  videoElement.removeEventListener('enterpictureinpicture', handlePiPEnter);
89085
88984
  videoElement.removeEventListener('leavepictureinpicture', handlePiPLeave);
89086
88985
  }
88986
+ // Unregister video element from PiP context
88987
+ unregisterVideoElement();
89087
88988
  };
89088
- }, [url]); // Re-run when URL changes to ensure proper cleanup and setup
88989
+ }, [url, enterPiP, exitPiP, registerVideoElement, unregisterVideoElement, isPlaying, videoState.volume, videoState.muted]); // Re-run when URL changes to ensure proper cleanup and setup
89089
88990
  useEffect(function () {
89090
88991
  setStartPlayed(false);
89091
- // Check if there's an active PiP session and restore state
89092
- if (pipManager.isPiPActive()) {
89093
- var savedState_1 = pipManager.getCurrentState();
89094
- if (savedState_1 && savedState_1.url === url) {
89095
- setIsPiPActive(true);
89096
- // Restore video state from PiP manager
89097
- setVideoState(function (prev) {
89098
- var _a;
89099
- return __assign(__assign({}, prev), {
89100
- volume: savedState_1.volume,
89101
- playbackRate: savedState_1.playbackRate,
89102
- played: savedState_1.currentTime / (((_a = videoPlayerRef.current) === null || _a === void 0 ? void 0 : _a.getDuration()) || 1)
89103
- });
89104
- });
89105
- setIsPlaying(savedState_1.isPlaying);
89106
- }
89107
- }
89108
- }, [url, setIsPlaying]);
88992
+ }, [url]);
89109
88993
  // Cleanup effect to handle component unmounting while in PiP mode
89110
88994
  useEffect(function () {
88995
+ var currentVideoPlayerRef = videoPlayerRef.current;
89111
88996
  return function () {
89112
- // Unregister from PiP manager when component unmounts
89113
- pipManager.unregisterVideo();
89114
88997
  // Check if we're in PiP mode when component unmounts
89115
88998
  if (document.pictureInPictureElement) {
89116
- // The PiP manager will handle keeping the video alive
89117
- console.log('Component unmounting while in Picture-in-Picture mode - PiP will persist');
88999
+ // Try to keep the video element alive by cloning it
89000
+ var videoElement = currentVideoPlayerRef === null || currentVideoPlayerRef === void 0 ? void 0 : currentVideoPlayerRef.getInternalPlayer();
89001
+ if (videoElement && videoElement instanceof HTMLVideoElement) {
89002
+ // Create a warning for the user that PiP will exit
89003
+ console.log('Component unmounting while in Picture-in-Picture mode');
89004
+ }
89118
89005
  }
89119
89006
  };
89120
89007
  }, []);
@@ -89288,18 +89175,9 @@ function usePlayerControls(_a) {
89288
89175
  if (videoPlayerRef.current && !startPlayed) {
89289
89176
  videoPlayerRef.current.seekTo(startTime);
89290
89177
  setStartPlayed(true);
89291
- // Register video with PiP manager when it's ready
89292
- var videoElement = videoPlayerRef.current.getInternalPlayer();
89293
- if (videoElement && videoElement instanceof HTMLVideoElement) {
89294
- // Restore state if there was a previous PiP session
89295
- var savedState = pipManager.getCurrentState();
89296
- if (savedState && savedState.url === url && pipManager.isPiPActive()) {
89297
- pipManager.restoreStateToVideo(videoElement);
89298
- }
89299
- }
89300
89178
  }
89301
89179
  setLoading(false);
89302
- }, [startTime, startPlayed, setLoading, url]);
89180
+ }, [startTime, startPlayed, setLoading]);
89303
89181
  var handleFullScreen = function handleFullScreen() {
89304
89182
  var playerContainer = playerContainerRef.current;
89305
89183
  if (!playerContainer) {
@@ -89321,37 +89199,19 @@ function usePlayerControls(_a) {
89321
89199
  console.warn('Picture-in-Picture is not supported in this browser');
89322
89200
  return;
89323
89201
  }
89324
- if (document.pictureInPictureElement) {
89325
- pipManager.exitPiP()["catch"](function (error) {
89326
- console.error('Failed to exit picture-in-picture:', error);
89327
- });
89202
+ if (isPiPActive) {
89203
+ // Exit PiP using context method
89204
+ exitPiP();
89328
89205
  } else {
89329
- // Register the video with the PiP manager
89330
- pipManager.registerVideo(videoElement, url, function (state) {
89331
- // Update local state when PiP video state changes
89332
- setVideoState(function (prev) {
89333
- return __assign(__assign({}, prev), {
89334
- played: state.currentTime / duration,
89335
- volume: state.volume,
89336
- playbackRate: state.playbackRate
89337
- });
89338
- });
89339
- setIsPlaying(state.isPlaying);
89340
- });
89341
- // Ensure the video is playing before entering PiP mode
89342
- if (videoElement.paused && isPlaying) {
89343
- videoElement.play().then(function () {
89344
- pipManager.enterPiP()["catch"](function (error) {
89345
- console.error('Failed to enter picture-in-picture:', error);
89346
- });
89347
- })["catch"](function (error) {
89348
- console.error('Failed to play video before PiP:', error);
89349
- });
89350
- } else {
89351
- pipManager.enterPiP()["catch"](function (error) {
89352
- console.error('Failed to enter picture-in-picture:', error);
89353
- });
89354
- }
89206
+ // Enter PiP using context method
89207
+ var pipVideoState = {
89208
+ url: url,
89209
+ currentTime: videoElement.currentTime,
89210
+ isPlaying: isPlaying,
89211
+ volume: videoState.volume,
89212
+ muted: videoState.muted
89213
+ };
89214
+ enterPiP(videoElement, pipVideoState);
89355
89215
  }
89356
89216
  };
89357
89217
  var handleKeyDown = useCallback(function (event) {
@@ -95055,4 +94915,4 @@ var RangeSlider = function RangeSlider(_a) {
95055
94915
  });
95056
94916
  };
95057
94917
 
95058
- export { AudioPlayer as A, Button$1 as B, CourseCard as C, DropDown as D, GridActionMenu as G, Loader as L, NavigationBar as N, PhoneCountryCode as P, RadioButton as R, SearchInput as S, TranslationProvider as T, Uploader as U, VideoPlayer as V, requirePatterns as a, ThemeProvider as b, CustomSwitcher as c, DatePicker as d, Checkbox as e, Pagination as f, getDefaultExportFromCjs as g, Breadcrumb as h, Tile as i, ColorPicker as j, Badge as k, TooltipHeight as l, CustomTooltip as m, SplashScreen as n, ColumnNavigation as o, StatusIndicator as p, TabPanel as q, requireUtils as r, TabNavigation as s, activeTabClassName as t, DrawerTips as u, RangeSlider as v };
94918
+ export { AudioPlayer as A, Button$1 as B, CourseCard as C, DropDown as D, GridActionMenu as G, Loader as L, NavigationBar as N, PhoneCountryCode as P, RadioButton as R, SearchInput as S, TranslationProvider as T, Uploader as U, VideoPlayer as V, requirePatterns as a, ThemeProvider as b, CustomSwitcher as c, DatePicker as d, Checkbox as e, Pagination as f, getDefaultExportFromCjs as g, Breadcrumb as h, Tile as i, ColorPicker as j, Badge as k, TooltipHeight as l, CustomTooltip as m, PiPProvider as n, SplashScreen as o, ColumnNavigation as p, StatusIndicator as q, requireUtils as r, TabPanel as s, TabNavigation as t, usePiP as u, activeTabClassName as v, DrawerTips as w, RangeSlider as x };
@@ -19,6 +19,8 @@ export { Badge } from './Badge';
19
19
  export { TooltipHeight } from './Tooltip';
20
20
  export { CustomTooltip } from './Tooltip';
21
21
  export { VideoPlayer } from './VideoPlayer';
22
+ export { PiPProvider } from './VideoPlayer/PiPContext';
23
+ export { usePiP } from './VideoPlayer/usePiP';
22
24
  export { SplashScreen } from './SplashScreen';
23
25
  export { AudioPlayer } from './AudioPlayer';
24
26
  export { ColumnNavigation } from './ColumnNavigation';
@@ -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-DKAGRUEW.esm.js';
1
+ export { A as AudioPlayer, k as Badge, h as Breadcrumb, B as Button, e as Checkbox, j as ColorPicker, p as ColumnNavigation, C as CourseCard, c as CustomSwitcher, m as CustomTooltip, d as DatePicker, w as DrawerTips, D as DropDown, G as GridActionMenu, L as Loader, N as NavigationBar, f as Pagination, P as PhoneCountryCode, n as PiPProvider, R as RadioButton, x as RangeSlider, S as SearchInput, o as SplashScreen, q as StatusIndicator, t as TabNavigation, s as TabPanel, b as ThemeProvider, i as Tile, l as TooltipHeight, T as TranslationProvider, U as Uploader, V as VideoPlayer, v as activeTabClassName, u as usePiP } from './index-F6zEoSWf.esm.js';
2
2
  import 'react';
3
3
  import 'react-dom';