@zezosoft/zezo-ott-react-native-video-player 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +330 -71
- package/lib/module/AdsPlayer/AdsPlayer.js +248 -0
- package/lib/module/AdsPlayer/AdsPlayer.js.map +1 -0
- package/lib/module/AdsPlayer/MediaControls/AdBottomControls.js +174 -0
- package/lib/module/AdsPlayer/MediaControls/AdBottomControls.js.map +1 -0
- package/lib/module/AdsPlayer/MediaControls/AdMediaControls.js +91 -0
- package/lib/module/AdsPlayer/MediaControls/AdMediaControls.js.map +1 -0
- package/lib/module/AdsPlayer/MediaControls/AdMediaControlsProvider.js +34 -0
- package/lib/module/AdsPlayer/MediaControls/AdMediaControlsProvider.js.map +1 -0
- package/lib/module/AdsPlayer/MediaControls/AdMiddleControls.js +65 -0
- package/lib/module/AdsPlayer/MediaControls/AdMiddleControls.js.map +1 -0
- package/lib/module/AdsPlayer/MediaControls/AdTopControls.js +189 -0
- package/lib/module/AdsPlayer/MediaControls/AdTopControls.js.map +1 -0
- package/lib/module/AdsPlayer/MediaControls/index.js +8 -0
- package/lib/module/AdsPlayer/MediaControls/index.js.map +1 -0
- package/lib/module/AdsPlayer/components/RotatingLoader.js +55 -0
- package/lib/module/AdsPlayer/components/RotatingLoader.js.map +1 -0
- package/lib/module/AdsPlayer/index.js +6 -0
- package/lib/module/AdsPlayer/index.js.map +1 -0
- package/lib/module/AdsPlayer/store/adsPlayer.type.js +4 -0
- package/lib/module/AdsPlayer/store/adsPlayer.type.js.map +1 -0
- package/lib/module/AdsPlayer/store/adsPlayerStore.js +70 -0
- package/lib/module/AdsPlayer/store/adsPlayerStore.js.map +1 -0
- package/lib/module/AdsPlayer/store/index.js +5 -0
- package/lib/module/AdsPlayer/store/index.js.map +1 -0
- package/lib/module/AdsPlayer/utils/adStateReset.js +31 -0
- package/lib/module/AdsPlayer/utils/adStateReset.js.map +1 -0
- package/lib/module/AdsPlayer/utils/controls.js +63 -0
- package/lib/module/AdsPlayer/utils/controls.js.map +1 -0
- package/lib/module/AdsPlayer/utils/useAdControlsAutoHide.js +35 -0
- package/lib/module/AdsPlayer/utils/useAdControlsAutoHide.js.map +1 -0
- package/lib/module/AdsPlayer/utils/useAdInitialization.js +60 -0
- package/lib/module/AdsPlayer/utils/useAdInitialization.js.map +1 -0
- package/lib/module/AdsPlayer/utils/useAdTracking.js +50 -0
- package/lib/module/AdsPlayer/utils/useAdTracking.js.map +1 -0
- package/lib/module/AdsPlayer/utils/useAdsManager.js +165 -0
- package/lib/module/AdsPlayer/utils/useAdsManager.js.map +1 -0
- package/lib/module/VideoPlayer/MediaControls/BottomControls.js +17 -6
- package/lib/module/VideoPlayer/MediaControls/BottomControls.js.map +1 -1
- package/lib/module/VideoPlayer/MediaControls/MediaControls.js +3 -1
- package/lib/module/VideoPlayer/MediaControls/MediaControls.js.map +1 -1
- package/lib/module/VideoPlayer/MediaControls/MediaControlsProvider.js +28 -31
- package/lib/module/VideoPlayer/MediaControls/MediaControlsProvider.js.map +1 -1
- package/lib/module/VideoPlayer/MediaControls/MiddleControls.js +50 -40
- package/lib/module/VideoPlayer/MediaControls/MiddleControls.js.map +1 -1
- package/lib/module/VideoPlayer/MediaControls/TopControls.js +11 -9
- package/lib/module/VideoPlayer/MediaControls/TopControls.js.map +1 -1
- package/lib/module/VideoPlayer/{model → Settings}/AudioAndSubtitles.js +0 -14
- package/lib/module/VideoPlayer/Settings/AudioAndSubtitles.js.map +1 -0
- package/lib/module/VideoPlayer/{model → Settings}/Episodes.js +1 -1
- package/lib/module/VideoPlayer/Settings/Episodes.js.map +1 -0
- package/lib/module/VideoPlayer/{model → Settings}/SettingModal.js +0 -1
- package/lib/module/VideoPlayer/Settings/SettingModal.js.map +1 -0
- package/lib/module/VideoPlayer/{model → Settings}/SpeedControls.js +1 -9
- package/lib/module/VideoPlayer/Settings/SpeedControls.js.map +1 -0
- package/lib/module/VideoPlayer/{model → Settings}/VideoPlayerSettings.js +1 -1
- package/lib/module/VideoPlayer/Settings/VideoPlayerSettings.js.map +1 -0
- package/lib/module/VideoPlayer/VideoPlayerCore.js +244 -0
- package/lib/module/VideoPlayer/VideoPlayerCore.js.map +1 -0
- package/lib/module/VideoPlayer/components/ProgressBar.js +63 -23
- package/lib/module/VideoPlayer/components/ProgressBar.js.map +1 -1
- package/lib/module/VideoPlayer/components/SkipAndNextControls.js +1 -6
- package/lib/module/VideoPlayer/components/SkipAndNextControls.js.map +1 -1
- package/lib/module/VideoPlayer/components/SubtitleView.js +1 -1
- package/lib/module/VideoPlayer/components/SubtitleView.js.map +1 -1
- package/lib/module/VideoPlayer/components/Toast.js +57 -0
- package/lib/module/VideoPlayer/components/Toast.js.map +1 -0
- package/lib/module/VideoPlayer/index.js +1 -1
- package/lib/module/VideoPlayer/index.js.map +1 -1
- package/lib/module/VideoPlayer/store/videoPlayerStore.js +0 -4
- package/lib/module/VideoPlayer/store/videoPlayerStore.js.map +1 -1
- package/lib/module/VideoPlayer/{Styles → styles}/globalStyles.js +5 -6
- package/lib/module/VideoPlayer/styles/globalStyles.js.map +1 -0
- package/lib/module/VideoPlayer/utils/{Display.js → display/Display.js} +0 -4
- package/lib/module/VideoPlayer/utils/display/Display.js.map +1 -0
- package/lib/module/VideoPlayer/utils/display/index.js +4 -0
- package/lib/module/VideoPlayer/utils/display/index.js.map +1 -0
- package/lib/module/VideoPlayer/utils/format/index.js +4 -0
- package/lib/module/VideoPlayer/utils/format/index.js.map +1 -0
- package/lib/module/VideoPlayer/utils/{timeFormatter.js → format/timeFormatter.js} +0 -6
- package/lib/module/VideoPlayer/utils/format/timeFormatter.js.map +1 -0
- package/lib/module/VideoPlayer/utils/hooks/index.js +3 -0
- package/lib/module/VideoPlayer/utils/hooks/index.js.map +1 -1
- package/lib/module/VideoPlayer/utils/hooks/useAdEventHandler.js +56 -0
- package/lib/module/VideoPlayer/utils/hooks/useAdEventHandler.js.map +1 -0
- package/lib/module/VideoPlayer/utils/hooks/useOrientationLock.js +25 -0
- package/lib/module/VideoPlayer/utils/hooks/useOrientationLock.js.map +1 -0
- package/lib/module/VideoPlayer/utils/hooks/usePauseVideoOnAd.js +43 -0
- package/lib/module/VideoPlayer/utils/hooks/usePauseVideoOnAd.js.map +1 -0
- package/lib/module/VideoPlayer/utils/hooks/useVideoPlayerBack.js +3 -4
- package/lib/module/VideoPlayer/utils/hooks/useVideoPlayerBack.js.map +1 -1
- package/lib/module/VideoPlayer/utils/hooks/useVideoResolutions.js +1 -4
- package/lib/module/VideoPlayer/utils/hooks/useVideoResolutions.js.map +1 -1
- package/lib/module/VideoPlayer/utils/index.js +5 -6
- package/lib/module/VideoPlayer/utils/index.js.map +1 -1
- package/lib/module/VideoPlayer/utils/{PlatformSelector.js → platform/PlatformSelector.js} +0 -5
- package/lib/module/VideoPlayer/utils/platform/PlatformSelector.js.map +1 -0
- package/lib/module/VideoPlayer/utils/platform/index.js +5 -0
- package/lib/module/VideoPlayer/utils/platform/index.js.map +1 -0
- package/lib/module/VideoPlayer/utils/{lockOrientation.js → platform/lockOrientation.js} +13 -5
- package/lib/module/VideoPlayer/utils/platform/lockOrientation.js.map +1 -0
- package/lib/module/VideoPlayer/utils/player/index.js +5 -0
- package/lib/module/VideoPlayer/utils/player/index.js.map +1 -0
- package/lib/module/VideoPlayer/utils/{playerEvents.js → player/playerEvents.js} +3 -3
- package/lib/module/VideoPlayer/utils/player/playerEvents.js.map +1 -0
- package/lib/module/VideoPlayer/utils/{useWatchReporter.js → player/useWatchReporter.js} +3 -2
- package/lib/module/VideoPlayer/utils/player/useWatchReporter.js.map +1 -0
- package/lib/module/VideoPlayer/utils/video/index.js +8 -0
- package/lib/module/VideoPlayer/utils/video/index.js.map +1 -0
- package/lib/module/VideoPlayer/utils/{videoControl.js → video/videoControl.js} +1 -14
- package/lib/module/VideoPlayer/utils/video/videoControl.js.map +1 -0
- package/lib/module/VideoPlayer/utils/video/videoRef.js +20 -0
- package/lib/module/VideoPlayer/utils/video/videoRef.js.map +1 -0
- package/lib/module/VideoPlayer/utils/video/videoResume.js +29 -0
- package/lib/module/VideoPlayer/utils/video/videoResume.js.map +1 -0
- package/lib/module/VideoPlayer/utils/video/videoSource.js.map +1 -0
- package/lib/module/VideoPlayer.js +128 -0
- package/lib/module/VideoPlayer.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/AdsPlayer/AdsPlayer.d.ts +22 -0
- package/lib/typescript/src/AdsPlayer/AdsPlayer.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/MediaControls/AdBottomControls.d.ts +4 -0
- package/lib/typescript/src/AdsPlayer/MediaControls/AdBottomControls.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/MediaControls/AdMediaControls.d.ts +8 -0
- package/lib/typescript/src/AdsPlayer/MediaControls/AdMediaControls.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/MediaControls/AdMediaControlsProvider.d.ts +26 -0
- package/lib/typescript/src/AdsPlayer/MediaControls/AdMediaControlsProvider.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/MediaControls/AdMiddleControls.d.ts +4 -0
- package/lib/typescript/src/AdsPlayer/MediaControls/AdMiddleControls.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/MediaControls/AdTopControls.d.ts +7 -0
- package/lib/typescript/src/AdsPlayer/MediaControls/AdTopControls.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/MediaControls/index.d.ts +6 -0
- package/lib/typescript/src/AdsPlayer/MediaControls/index.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/components/RotatingLoader.d.ts +12 -0
- package/lib/typescript/src/AdsPlayer/components/RotatingLoader.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/index.d.ts +5 -0
- package/lib/typescript/src/AdsPlayer/index.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/store/adsPlayer.type.d.ts +28 -0
- package/lib/typescript/src/AdsPlayer/store/adsPlayer.type.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/store/adsPlayerStore.d.ts +22 -0
- package/lib/typescript/src/AdsPlayer/store/adsPlayerStore.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/store/index.d.ts +3 -0
- package/lib/typescript/src/AdsPlayer/store/index.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/utils/adStateReset.d.ts +6 -0
- package/lib/typescript/src/AdsPlayer/utils/adStateReset.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/utils/controls.d.ts +13 -0
- package/lib/typescript/src/AdsPlayer/utils/controls.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/utils/useAdControlsAutoHide.d.ts +3 -0
- package/lib/typescript/src/AdsPlayer/utils/useAdControlsAutoHide.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/utils/useAdInitialization.d.ts +20 -0
- package/lib/typescript/src/AdsPlayer/utils/useAdInitialization.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/utils/useAdTracking.d.ts +23 -0
- package/lib/typescript/src/AdsPlayer/utils/useAdTracking.d.ts.map +1 -0
- package/lib/typescript/src/AdsPlayer/utils/useAdsManager.d.ts +9 -0
- package/lib/typescript/src/AdsPlayer/utils/useAdsManager.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/MediaControls/BottomControls.d.ts.map +1 -1
- package/lib/typescript/src/VideoPlayer/MediaControls/MediaControls.d.ts.map +1 -1
- package/lib/typescript/src/VideoPlayer/MediaControls/MediaControlsProvider.d.ts +3 -1
- package/lib/typescript/src/VideoPlayer/MediaControls/MediaControlsProvider.d.ts.map +1 -1
- package/lib/typescript/src/VideoPlayer/MediaControls/MiddleControls.d.ts +2 -1
- package/lib/typescript/src/VideoPlayer/MediaControls/MiddleControls.d.ts.map +1 -1
- package/lib/typescript/src/VideoPlayer/MediaControls/TopControls.d.ts.map +1 -1
- package/lib/typescript/src/VideoPlayer/Settings/AudioAndSubtitles.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/{model → Settings}/Episodes.d.ts +1 -1
- package/lib/typescript/src/VideoPlayer/Settings/Episodes.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/{model → Settings}/SettingModal.d.ts +1 -1
- package/lib/typescript/src/VideoPlayer/Settings/SettingModal.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/Settings/SpeedControls.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/Settings/VideoPlayerSettings.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/{VideoPlayer.d.ts → VideoPlayerCore.d.ts} +10 -7
- package/lib/typescript/src/VideoPlayer/VideoPlayerCore.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/components/ProgressBar.d.ts +3 -1
- package/lib/typescript/src/VideoPlayer/components/ProgressBar.d.ts.map +1 -1
- package/lib/typescript/src/VideoPlayer/components/SkipAndNextControls.d.ts +1 -1
- package/lib/typescript/src/VideoPlayer/components/SkipAndNextControls.d.ts.map +1 -1
- package/lib/typescript/src/VideoPlayer/components/Toast.d.ts +12 -0
- package/lib/typescript/src/VideoPlayer/components/Toast.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/index.d.ts +1 -1
- package/lib/typescript/src/VideoPlayer/index.d.ts.map +1 -1
- package/lib/typescript/src/VideoPlayer/store/videoPlayer.type.d.ts +25 -5
- package/lib/typescript/src/VideoPlayer/store/videoPlayer.type.d.ts.map +1 -1
- package/lib/typescript/src/VideoPlayer/store/videoPlayerStore.d.ts.map +1 -1
- package/lib/typescript/src/VideoPlayer/{Styles → styles}/globalStyles.d.ts +16 -9
- package/lib/typescript/src/VideoPlayer/styles/globalStyles.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/display/Display.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/display/index.d.ts +2 -0
- package/lib/typescript/src/VideoPlayer/utils/display/index.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/format/index.d.ts +2 -0
- package/lib/typescript/src/VideoPlayer/utils/format/index.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/{timeFormatter.d.ts → format/timeFormatter.d.ts} +0 -5
- package/lib/typescript/src/VideoPlayer/utils/format/timeFormatter.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/hooks/index.d.ts +3 -0
- package/lib/typescript/src/VideoPlayer/utils/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/VideoPlayer/utils/hooks/useAdEventHandler.d.ts +34 -0
- package/lib/typescript/src/VideoPlayer/utils/hooks/useAdEventHandler.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/hooks/useOrientationLock.d.ts +11 -0
- package/lib/typescript/src/VideoPlayer/utils/hooks/useOrientationLock.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/hooks/usePauseVideoOnAd.d.ts +6 -0
- package/lib/typescript/src/VideoPlayer/utils/hooks/usePauseVideoOnAd.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/hooks/useVideoResolutions.d.ts.map +1 -1
- package/lib/typescript/src/VideoPlayer/utils/index.d.ts +5 -6
- package/lib/typescript/src/VideoPlayer/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/VideoPlayer/utils/{PlatformSelector.d.ts → platform/PlatformSelector.d.ts} +0 -4
- package/lib/typescript/src/VideoPlayer/utils/platform/PlatformSelector.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/platform/index.d.ts +3 -0
- package/lib/typescript/src/VideoPlayer/utils/platform/index.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/platform/lockOrientation.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/player/index.d.ts +3 -0
- package/lib/typescript/src/VideoPlayer/utils/player/index.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/{playerEvents.d.ts → player/playerEvents.d.ts} +1 -1
- package/lib/typescript/src/VideoPlayer/utils/player/playerEvents.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/{useWatchReporter.d.ts → player/useWatchReporter.d.ts} +1 -6
- package/lib/typescript/src/VideoPlayer/utils/player/useWatchReporter.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/video/index.d.ts +6 -0
- package/lib/typescript/src/VideoPlayer/utils/video/index.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/{videoControl.d.ts → video/videoControl.d.ts} +1 -1
- package/lib/typescript/src/VideoPlayer/utils/video/videoControl.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/video/videoRef.d.ts +19 -0
- package/lib/typescript/src/VideoPlayer/utils/video/videoRef.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/video/videoResume.d.ts +6 -0
- package/lib/typescript/src/VideoPlayer/utils/video/videoResume.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer/utils/{videoSource.d.ts → video/videoSource.d.ts} +1 -1
- package/lib/typescript/src/VideoPlayer/utils/video/videoSource.d.ts.map +1 -0
- package/lib/typescript/src/VideoPlayer.d.ts +31 -0
- package/lib/typescript/src/VideoPlayer.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +125 -101
- package/src/AdsPlayer/AdsPlayer.tsx +312 -0
- package/src/AdsPlayer/MediaControls/AdBottomControls.tsx +189 -0
- package/src/AdsPlayer/MediaControls/AdMediaControls.tsx +98 -0
- package/src/AdsPlayer/MediaControls/AdMediaControlsProvider.tsx +62 -0
- package/src/AdsPlayer/MediaControls/AdMiddleControls.tsx +63 -0
- package/src/AdsPlayer/MediaControls/AdTopControls.tsx +196 -0
- package/src/AdsPlayer/MediaControls/index.ts +5 -0
- package/src/AdsPlayer/components/RotatingLoader.tsx +79 -0
- package/src/AdsPlayer/index.ts +4 -0
- package/src/AdsPlayer/store/adsPlayer.type.ts +29 -0
- package/src/AdsPlayer/store/adsPlayerStore.ts +59 -0
- package/src/AdsPlayer/store/index.ts +2 -0
- package/src/AdsPlayer/utils/adStateReset.ts +29 -0
- package/src/AdsPlayer/utils/controls.ts +69 -0
- package/src/AdsPlayer/utils/useAdControlsAutoHide.ts +32 -0
- package/src/AdsPlayer/utils/useAdInitialization.ts +86 -0
- package/src/AdsPlayer/utils/useAdTracking.ts +89 -0
- package/src/AdsPlayer/utils/useAdsManager.ts +215 -0
- package/src/VideoPlayer/MediaControls/BottomControls.tsx +22 -3
- package/src/VideoPlayer/MediaControls/MediaControls.tsx +3 -2
- package/src/VideoPlayer/MediaControls/MediaControlsProvider.tsx +36 -35
- package/src/VideoPlayer/MediaControls/MiddleControls.tsx +87 -60
- package/src/VideoPlayer/MediaControls/TopControls.tsx +21 -7
- package/src/VideoPlayer/{model → Settings}/AudioAndSubtitles.tsx +0 -7
- package/src/VideoPlayer/{model → Settings}/Episodes.tsx +6 -3
- package/src/VideoPlayer/{model → Settings}/SettingModal.tsx +1 -2
- package/src/VideoPlayer/{model → Settings}/SpeedControls.tsx +1 -5
- package/src/VideoPlayer/{model → Settings}/VideoPlayerSettings.tsx +1 -1
- package/src/VideoPlayer/VideoPlayerCore.tsx +356 -0
- package/src/VideoPlayer/components/ProgressBar.tsx +85 -21
- package/src/VideoPlayer/components/SkipAndNextControls.tsx +2 -5
- package/src/VideoPlayer/components/SubtitleView.tsx +1 -1
- package/src/VideoPlayer/components/Toast.tsx +61 -0
- package/src/VideoPlayer/index.ts +1 -1
- package/src/VideoPlayer/store/videoPlayer.type.ts +28 -6
- package/src/VideoPlayer/store/videoPlayerStore.ts +0 -4
- package/src/VideoPlayer/{Styles → styles}/globalStyles.ts +5 -6
- package/src/VideoPlayer/utils/{Display.ts → display/Display.ts} +0 -4
- package/src/VideoPlayer/utils/display/index.ts +1 -0
- package/src/VideoPlayer/utils/format/index.ts +1 -0
- package/src/VideoPlayer/utils/{timeFormatter.ts → format/timeFormatter.ts} +4 -7
- package/src/VideoPlayer/utils/hooks/index.ts +3 -0
- package/src/VideoPlayer/utils/hooks/useAdEventHandler.ts +95 -0
- package/src/VideoPlayer/utils/hooks/useOrientationLock.ts +29 -0
- package/src/VideoPlayer/utils/hooks/usePauseVideoOnAd.ts +46 -0
- package/src/VideoPlayer/utils/hooks/useVideoPlayerBack.ts +3 -3
- package/src/VideoPlayer/utils/hooks/useVideoResolutions.ts +1 -3
- package/src/VideoPlayer/utils/index.ts +5 -6
- package/src/VideoPlayer/utils/{PlatformSelector.ts → platform/PlatformSelector.ts} +0 -5
- package/src/VideoPlayer/utils/platform/index.ts +2 -0
- package/src/VideoPlayer/utils/{lockOrientation.ts → platform/lockOrientation.ts} +11 -5
- package/src/VideoPlayer/utils/player/index.ts +2 -0
- package/src/VideoPlayer/utils/{playerEvents.ts → player/playerEvents.ts} +4 -4
- package/src/VideoPlayer/utils/{useWatchReporter.ts → player/useWatchReporter.ts} +4 -3
- package/src/VideoPlayer/utils/video/index.ts +5 -0
- package/src/VideoPlayer/utils/{videoControl.ts → video/videoControl.ts} +2 -9
- package/src/VideoPlayer/utils/video/videoRef.ts +21 -0
- package/src/VideoPlayer/utils/video/videoResume.ts +23 -0
- package/src/VideoPlayer/utils/{videoSource.ts → video/videoSource.ts} +1 -1
- package/src/VideoPlayer.tsx +166 -0
- package/src/index.tsx +3 -1
- package/lib/module/VideoPlayer/Styles/fonts.js +0 -58
- package/lib/module/VideoPlayer/Styles/fonts.js.map +0 -1
- package/lib/module/VideoPlayer/Styles/globalStyles.js.map +0 -1
- package/lib/module/VideoPlayer/VideoPlayer.js +0 -180
- package/lib/module/VideoPlayer/VideoPlayer.js.map +0 -1
- package/lib/module/VideoPlayer/model/AudioAndSubtitles.js.map +0 -1
- package/lib/module/VideoPlayer/model/Episodes.js.map +0 -1
- package/lib/module/VideoPlayer/model/SettingModal.js.map +0 -1
- package/lib/module/VideoPlayer/model/SpeedControls.js.map +0 -1
- package/lib/module/VideoPlayer/model/VideoPlayerSettings.js.map +0 -1
- package/lib/module/VideoPlayer/utils/Display.js.map +0 -1
- package/lib/module/VideoPlayer/utils/PlatformSelector.js.map +0 -1
- package/lib/module/VideoPlayer/utils/lockOrientation.js.map +0 -1
- package/lib/module/VideoPlayer/utils/playerEvents.js.map +0 -1
- package/lib/module/VideoPlayer/utils/timeFormatter.js.map +0 -1
- package/lib/module/VideoPlayer/utils/useWatchReporter.js.map +0 -1
- package/lib/module/VideoPlayer/utils/videoControl.js.map +0 -1
- package/lib/module/VideoPlayer/utils/videoRef.js +0 -5
- package/lib/module/VideoPlayer/utils/videoRef.js.map +0 -1
- package/lib/module/VideoPlayer/utils/videoSource.js.map +0 -1
- package/lib/typescript/src/VideoPlayer/Styles/fonts.d.ts +0 -54
- package/lib/typescript/src/VideoPlayer/Styles/fonts.d.ts.map +0 -1
- package/lib/typescript/src/VideoPlayer/Styles/globalStyles.d.ts.map +0 -1
- package/lib/typescript/src/VideoPlayer/VideoPlayer.d.ts.map +0 -1
- package/lib/typescript/src/VideoPlayer/model/AudioAndSubtitles.d.ts.map +0 -1
- package/lib/typescript/src/VideoPlayer/model/Episodes.d.ts.map +0 -1
- package/lib/typescript/src/VideoPlayer/model/SettingModal.d.ts.map +0 -1
- package/lib/typescript/src/VideoPlayer/model/SpeedControls.d.ts.map +0 -1
- package/lib/typescript/src/VideoPlayer/model/VideoPlayerSettings.d.ts.map +0 -1
- package/lib/typescript/src/VideoPlayer/utils/Display.d.ts.map +0 -1
- package/lib/typescript/src/VideoPlayer/utils/PlatformSelector.d.ts.map +0 -1
- package/lib/typescript/src/VideoPlayer/utils/lockOrientation.d.ts.map +0 -1
- package/lib/typescript/src/VideoPlayer/utils/playerEvents.d.ts.map +0 -1
- package/lib/typescript/src/VideoPlayer/utils/timeFormatter.d.ts.map +0 -1
- package/lib/typescript/src/VideoPlayer/utils/useWatchReporter.d.ts.map +0 -1
- package/lib/typescript/src/VideoPlayer/utils/videoControl.d.ts.map +0 -1
- package/lib/typescript/src/VideoPlayer/utils/videoRef.d.ts +0 -3
- package/lib/typescript/src/VideoPlayer/utils/videoRef.d.ts.map +0 -1
- package/lib/typescript/src/VideoPlayer/utils/videoSource.d.ts.map +0 -1
- package/src/VideoPlayer/Styles/fonts.ts +0 -106
- package/src/VideoPlayer/VideoPlayer.tsx +0 -217
- package/src/VideoPlayer/utils/videoRef.ts +0 -4
- /package/lib/module/VideoPlayer/utils/{videoSource.js → video/videoSource.js} +0 -0
- /package/lib/typescript/src/VideoPlayer/{model → Settings}/AudioAndSubtitles.d.ts +0 -0
- /package/lib/typescript/src/VideoPlayer/{model → Settings}/SpeedControls.d.ts +0 -0
- /package/lib/typescript/src/VideoPlayer/{model → Settings}/VideoPlayerSettings.d.ts +0 -0
- /package/lib/typescript/src/VideoPlayer/utils/{Display.d.ts → display/Display.d.ts} +0 -0
- /package/lib/typescript/src/VideoPlayer/utils/{lockOrientation.d.ts → platform/lockOrientation.d.ts} +0 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { memo, useCallback, useMemo } from 'react';
|
|
2
|
+
import { Animated, StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
import { scale } from 'react-native-size-matters';
|
|
4
|
+
import { Play, Pause } from 'lucide-react-native';
|
|
5
|
+
import { useAdsPlayerStore } from '../store/adsPlayerStore';
|
|
6
|
+
import { useAdControlsAutoHide } from '../utils/useAdControlsAutoHide';
|
|
7
|
+
import RotatingLoader from '../components/RotatingLoader';
|
|
8
|
+
import globalStyles from '../../VideoPlayer/styles/globalStyles';
|
|
9
|
+
|
|
10
|
+
const AdMiddleControls: React.FC = () => {
|
|
11
|
+
const { isAdPaused, isAdBuffering, setIsAdPaused } = useAdsPlayerStore();
|
|
12
|
+
const fadeAnim = useAdControlsAutoHide();
|
|
13
|
+
|
|
14
|
+
const handlePlayPause = useCallback(() => {
|
|
15
|
+
setIsAdPaused(!isAdPaused);
|
|
16
|
+
}, [isAdPaused, setIsAdPaused]);
|
|
17
|
+
|
|
18
|
+
// Memoize container style
|
|
19
|
+
const containerStyle = useMemo(
|
|
20
|
+
() => [styles.container, { opacity: fadeAnim }],
|
|
21
|
+
[fadeAnim]
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Animated.View style={containerStyle} pointerEvents="box-none">
|
|
26
|
+
{isAdBuffering ? (
|
|
27
|
+
<RotatingLoader
|
|
28
|
+
color="#fff"
|
|
29
|
+
autoRotate={isAdBuffering}
|
|
30
|
+
size={scale(50)}
|
|
31
|
+
/>
|
|
32
|
+
) : (
|
|
33
|
+
<View pointerEvents="auto">
|
|
34
|
+
<TouchableOpacity
|
|
35
|
+
onPress={handlePlayPause}
|
|
36
|
+
style={styles.button}
|
|
37
|
+
activeOpacity={0.7}
|
|
38
|
+
>
|
|
39
|
+
{isAdPaused ? (
|
|
40
|
+
<Play size={scale(40)} color="#fff" fill="#fff" />
|
|
41
|
+
) : (
|
|
42
|
+
<Pause size={scale(40)} color="#fff" fill="#fff" />
|
|
43
|
+
)}
|
|
44
|
+
</TouchableOpacity>
|
|
45
|
+
</View>
|
|
46
|
+
)}
|
|
47
|
+
</Animated.View>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const styles = StyleSheet.create({
|
|
52
|
+
container: {
|
|
53
|
+
...globalStyles.absoluteFill,
|
|
54
|
+
justifyContent: 'center',
|
|
55
|
+
alignItems: 'center',
|
|
56
|
+
},
|
|
57
|
+
button: {
|
|
58
|
+
justifyContent: 'center',
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export default memo(AdMiddleControls);
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Animated,
|
|
4
|
+
StyleSheet,
|
|
5
|
+
Text,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
View,
|
|
8
|
+
Platform,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import { moderateScale } from 'react-native-size-matters';
|
|
11
|
+
import { RFValue } from 'react-native-responsive-fontsize';
|
|
12
|
+
import { X } from 'lucide-react-native';
|
|
13
|
+
import { useVideoPlayerStore } from '../../VideoPlayer/store/videoPlayerStore';
|
|
14
|
+
import { useAdsPlayerStore } from '../store/adsPlayerStore';
|
|
15
|
+
import { useAdControlsAutoHide } from '../utils/useAdControlsAutoHide';
|
|
16
|
+
import { formatTime } from '../../VideoPlayer/utils';
|
|
17
|
+
|
|
18
|
+
interface AdTopControlsProps {
|
|
19
|
+
onClose?: () => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const AdTopControls: React.FC<AdTopControlsProps> = ({ onClose }) => {
|
|
23
|
+
const controlsVisible = useVideoPlayerStore((state) => state.controlsVisible);
|
|
24
|
+
const currentAd = useAdsPlayerStore((state) => state.currentAd);
|
|
25
|
+
const adCurrentTime = useAdsPlayerStore((state) => state.adCurrentTime);
|
|
26
|
+
const fadeAnim = useAdControlsAutoHide();
|
|
27
|
+
|
|
28
|
+
// Memoize styles to avoid recalculation
|
|
29
|
+
const adLabelContainerStyle = useMemo(
|
|
30
|
+
() => [
|
|
31
|
+
styles.adLabelContainer,
|
|
32
|
+
controlsVisible
|
|
33
|
+
? styles.adLabelContainerVisible
|
|
34
|
+
: styles.adLabelContainerHidden,
|
|
35
|
+
],
|
|
36
|
+
[controlsVisible]
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const adBadgeStyle = useMemo(
|
|
40
|
+
() => [
|
|
41
|
+
styles.adBadge,
|
|
42
|
+
controlsVisible ? styles.adBadgeVisible : styles.adBadgeHidden,
|
|
43
|
+
],
|
|
44
|
+
[controlsVisible]
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const closeButtonStyle = useMemo(
|
|
48
|
+
() => [styles.closeButtonContainer, { opacity: fadeAnim }],
|
|
49
|
+
[fadeAnim]
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<View style={styles.container}>
|
|
54
|
+
{currentAd && (
|
|
55
|
+
<Animated.View style={adLabelContainerStyle}>
|
|
56
|
+
<View style={adBadgeStyle}>
|
|
57
|
+
<View style={styles.adLabelWrapper}>
|
|
58
|
+
<Text style={styles.adLabelText}>Ad</Text>
|
|
59
|
+
</View>
|
|
60
|
+
<View style={styles.separator} />
|
|
61
|
+
<Text style={styles.adTimeText}>{formatTime(adCurrentTime)}</Text>
|
|
62
|
+
</View>
|
|
63
|
+
</Animated.View>
|
|
64
|
+
)}
|
|
65
|
+
<Animated.View style={closeButtonStyle}>
|
|
66
|
+
<TouchableOpacity
|
|
67
|
+
onPress={onClose}
|
|
68
|
+
style={styles.closeButton}
|
|
69
|
+
activeOpacity={0.7}
|
|
70
|
+
>
|
|
71
|
+
<View style={styles.closeButtonBackground}>
|
|
72
|
+
<X size={moderateScale(22)} color="#fff" strokeWidth={2.5} />
|
|
73
|
+
</View>
|
|
74
|
+
</TouchableOpacity>
|
|
75
|
+
</Animated.View>
|
|
76
|
+
</View>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const styles = StyleSheet.create({
|
|
81
|
+
container: {
|
|
82
|
+
flexDirection: 'row',
|
|
83
|
+
justifyContent: 'space-between',
|
|
84
|
+
alignItems: 'flex-start',
|
|
85
|
+
marginTop: moderateScale(8),
|
|
86
|
+
paddingHorizontal: moderateScale(10),
|
|
87
|
+
paddingBottom: 0,
|
|
88
|
+
},
|
|
89
|
+
adLabelContainer: {
|
|
90
|
+
flex: 1,
|
|
91
|
+
alignItems: 'flex-start',
|
|
92
|
+
},
|
|
93
|
+
adLabelContainerVisible: {
|
|
94
|
+
opacity: 1,
|
|
95
|
+
},
|
|
96
|
+
adLabelContainerHidden: {
|
|
97
|
+
opacity: 0.95,
|
|
98
|
+
},
|
|
99
|
+
adBadge: {
|
|
100
|
+
flexDirection: 'row',
|
|
101
|
+
alignItems: 'center',
|
|
102
|
+
borderRadius: moderateScale(8),
|
|
103
|
+
paddingHorizontal: moderateScale(5),
|
|
104
|
+
paddingVertical: moderateScale(3),
|
|
105
|
+
borderWidth: 1,
|
|
106
|
+
},
|
|
107
|
+
adBadgeVisible: {
|
|
108
|
+
backgroundColor: 'rgba(0, 0, 0, 0.85)',
|
|
109
|
+
borderColor: 'rgba(255, 255, 255, 0.2)',
|
|
110
|
+
...Platform.select({
|
|
111
|
+
ios: {
|
|
112
|
+
shadowColor: '#000',
|
|
113
|
+
shadowOffset: { width: 0, height: 2 },
|
|
114
|
+
shadowOpacity: 0.4,
|
|
115
|
+
shadowRadius: 5,
|
|
116
|
+
},
|
|
117
|
+
android: {
|
|
118
|
+
elevation: 5,
|
|
119
|
+
},
|
|
120
|
+
}),
|
|
121
|
+
},
|
|
122
|
+
adBadgeHidden: {
|
|
123
|
+
backgroundColor: 'rgba(0, 0, 0, 0.9)',
|
|
124
|
+
borderColor: 'rgba(255, 255, 255, 0.15)',
|
|
125
|
+
...Platform.select({
|
|
126
|
+
ios: {
|
|
127
|
+
shadowColor: '#000',
|
|
128
|
+
shadowOffset: { width: 0, height: 2 },
|
|
129
|
+
shadowOpacity: 0.3,
|
|
130
|
+
shadowRadius: 4,
|
|
131
|
+
},
|
|
132
|
+
android: {
|
|
133
|
+
elevation: 4,
|
|
134
|
+
},
|
|
135
|
+
}),
|
|
136
|
+
},
|
|
137
|
+
adLabelWrapper: {
|
|
138
|
+
backgroundColor: 'rgb(255, 255, 255)',
|
|
139
|
+
borderRadius: moderateScale(3),
|
|
140
|
+
paddingHorizontal: moderateScale(5),
|
|
141
|
+
paddingVertical: moderateScale(1),
|
|
142
|
+
},
|
|
143
|
+
adLabelText: {
|
|
144
|
+
color: 'red',
|
|
145
|
+
fontSize: RFValue(10),
|
|
146
|
+
fontWeight: '700',
|
|
147
|
+
letterSpacing: 0.1,
|
|
148
|
+
textTransform: 'uppercase',
|
|
149
|
+
},
|
|
150
|
+
separator: {
|
|
151
|
+
width: 1,
|
|
152
|
+
height: moderateScale(12),
|
|
153
|
+
backgroundColor: 'rgba(255, 255, 255, 0.3)',
|
|
154
|
+
marginHorizontal: moderateScale(5),
|
|
155
|
+
},
|
|
156
|
+
adTimeText: {
|
|
157
|
+
color: '#fff',
|
|
158
|
+
fontSize: RFValue(13),
|
|
159
|
+
fontWeight: '700',
|
|
160
|
+
fontVariant: ['tabular-nums'],
|
|
161
|
+
letterSpacing: 0.3,
|
|
162
|
+
minWidth: moderateScale(40),
|
|
163
|
+
},
|
|
164
|
+
closeButtonContainer: {
|
|
165
|
+
justifyContent: 'flex-end',
|
|
166
|
+
alignItems: 'flex-end',
|
|
167
|
+
},
|
|
168
|
+
closeButton: {
|
|
169
|
+
justifyContent: 'center',
|
|
170
|
+
alignItems: 'center',
|
|
171
|
+
padding: moderateScale(2),
|
|
172
|
+
},
|
|
173
|
+
closeButtonBackground: {
|
|
174
|
+
width: moderateScale(32),
|
|
175
|
+
height: moderateScale(32),
|
|
176
|
+
borderRadius: moderateScale(16),
|
|
177
|
+
backgroundColor: 'rgba(0, 0, 0, 0.6)',
|
|
178
|
+
justifyContent: 'center',
|
|
179
|
+
alignItems: 'center',
|
|
180
|
+
borderWidth: 1,
|
|
181
|
+
borderColor: 'rgba(255, 255, 255, 0.2)',
|
|
182
|
+
...Platform.select({
|
|
183
|
+
ios: {
|
|
184
|
+
shadowColor: '#000',
|
|
185
|
+
shadowOffset: { width: 0, height: 2 },
|
|
186
|
+
shadowOpacity: 0.25,
|
|
187
|
+
shadowRadius: 3,
|
|
188
|
+
},
|
|
189
|
+
android: {
|
|
190
|
+
elevation: 3,
|
|
191
|
+
},
|
|
192
|
+
}),
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
export default memo(AdTopControls);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as AdMediaControls } from './AdMediaControls';
|
|
2
|
+
export { default as AdMediaControlsProvider } from './AdMediaControlsProvider';
|
|
3
|
+
export { default as AdTopControls } from './AdTopControls';
|
|
4
|
+
export { default as AdMiddleControls } from './AdMiddleControls';
|
|
5
|
+
export { default as AdBottomControls } from './AdBottomControls';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
StyleSheet,
|
|
4
|
+
Animated,
|
|
5
|
+
Easing,
|
|
6
|
+
type StyleProp,
|
|
7
|
+
type ViewStyle,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import { Loader } from 'lucide-react-native';
|
|
10
|
+
import { moderateScale } from 'react-native-size-matters';
|
|
11
|
+
|
|
12
|
+
interface RotatingLoaderProps {
|
|
13
|
+
size?: number;
|
|
14
|
+
color?: string;
|
|
15
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
16
|
+
rotationDuration?: number;
|
|
17
|
+
autoRotate?: boolean; // Whether to auto-rotate (default: true)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const RotatingLoader: React.FC<RotatingLoaderProps> = ({
|
|
21
|
+
size = moderateScale(35),
|
|
22
|
+
color = '#fff',
|
|
23
|
+
containerStyle,
|
|
24
|
+
rotationDuration = 1300,
|
|
25
|
+
autoRotate = true,
|
|
26
|
+
}) => {
|
|
27
|
+
const rotateAnim = useRef(new Animated.Value(0)).current;
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (autoRotate) {
|
|
31
|
+
rotateAnim.setValue(0);
|
|
32
|
+
const animation = Animated.loop(
|
|
33
|
+
Animated.timing(rotateAnim, {
|
|
34
|
+
toValue: 1,
|
|
35
|
+
duration: rotationDuration,
|
|
36
|
+
easing: Easing.linear,
|
|
37
|
+
useNativeDriver: true,
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
animation.start();
|
|
41
|
+
|
|
42
|
+
return () => {
|
|
43
|
+
animation.stop();
|
|
44
|
+
rotateAnim.stopAnimation();
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}, [autoRotate, rotationDuration, rotateAnim]);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Animated.View
|
|
52
|
+
style={[
|
|
53
|
+
styles.container,
|
|
54
|
+
containerStyle,
|
|
55
|
+
{
|
|
56
|
+
transform: [
|
|
57
|
+
{
|
|
58
|
+
rotate: rotateAnim.interpolate({
|
|
59
|
+
inputRange: [0, 1],
|
|
60
|
+
outputRange: ['0deg', '360deg'],
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
]}
|
|
66
|
+
>
|
|
67
|
+
<Loader size={size} color={color} />
|
|
68
|
+
</Animated.View>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default RotatingLoader;
|
|
73
|
+
|
|
74
|
+
const styles = StyleSheet.create({
|
|
75
|
+
container: {
|
|
76
|
+
justifyContent: 'center',
|
|
77
|
+
alignItems: 'center',
|
|
78
|
+
},
|
|
79
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { VideoAd } from '../../VideoPlayer/store/videoPlayer.type';
|
|
2
|
+
|
|
3
|
+
export interface AdState {
|
|
4
|
+
currentAd: VideoAd | null;
|
|
5
|
+
isAdPlaying: boolean;
|
|
6
|
+
isAdPaused: boolean;
|
|
7
|
+
isAdMuted: boolean;
|
|
8
|
+
isAdBuffering: boolean;
|
|
9
|
+
adCurrentTime: number;
|
|
10
|
+
adDuration: number;
|
|
11
|
+
pendingMidRollAds: VideoAd[];
|
|
12
|
+
showSkipButton: boolean;
|
|
13
|
+
resumeTime: number | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface AdsPlayerStore extends AdState {
|
|
17
|
+
setCurrentAd: (ad: VideoAd | null) => void;
|
|
18
|
+
setIsAdPlaying: (isPlaying: boolean) => void;
|
|
19
|
+
setIsAdPaused: (isPaused: boolean) => void;
|
|
20
|
+
setIsAdMuted: (isMuted: boolean) => void;
|
|
21
|
+
setIsAdBuffering: (isBuffering: boolean) => void;
|
|
22
|
+
setAdCurrentTime: (time: number) => void;
|
|
23
|
+
setAdDuration: (duration: number) => void;
|
|
24
|
+
setShowSkipButton: (show: boolean) => void;
|
|
25
|
+
addPendingMidRollAd: (ad: VideoAd) => void;
|
|
26
|
+
clearPendingMidRollAds: () => void;
|
|
27
|
+
setResumeTime: (time: number | null) => void;
|
|
28
|
+
resetAdsStore: () => void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { createJSONStorage, persist } from 'zustand/middleware';
|
|
3
|
+
import { MMKV } from 'react-native-mmkv';
|
|
4
|
+
import type { AdsPlayerStore, AdState } from './adsPlayer.type';
|
|
5
|
+
|
|
6
|
+
export const adsStorage = new MMKV({
|
|
7
|
+
id: 'adsPlayerStorage',
|
|
8
|
+
encryptionKey: 'adsPlayerKey',
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const adsMmkvStorage = {
|
|
12
|
+
setItem: (key: string, value: string) => adsStorage.set(key, value),
|
|
13
|
+
getItem: (key: string) => adsStorage.getString(key) ?? null,
|
|
14
|
+
removeItem: (key: string) => adsStorage.delete(key),
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const adsStoreDataDefaults: AdState = {
|
|
18
|
+
currentAd: null,
|
|
19
|
+
isAdPlaying: false,
|
|
20
|
+
isAdPaused: false,
|
|
21
|
+
isAdMuted: false,
|
|
22
|
+
isAdBuffering: false,
|
|
23
|
+
adCurrentTime: 0,
|
|
24
|
+
adDuration: 0,
|
|
25
|
+
pendingMidRollAds: [],
|
|
26
|
+
showSkipButton: false,
|
|
27
|
+
resumeTime: null,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const useAdsPlayerStore = create<AdsPlayerStore>()(
|
|
31
|
+
persist(
|
|
32
|
+
(set) => ({
|
|
33
|
+
...adsStoreDataDefaults,
|
|
34
|
+
|
|
35
|
+
setCurrentAd: (currentAd) => set({ currentAd }),
|
|
36
|
+
setIsAdPlaying: (isAdPlaying) => set({ isAdPlaying }),
|
|
37
|
+
setIsAdPaused: (isAdPaused) => set({ isAdPaused }),
|
|
38
|
+
setIsAdMuted: (isAdMuted) => set({ isAdMuted }),
|
|
39
|
+
setIsAdBuffering: (isAdBuffering) => set({ isAdBuffering }),
|
|
40
|
+
setAdCurrentTime: (adCurrentTime) => set({ adCurrentTime }),
|
|
41
|
+
setAdDuration: (adDuration) => set({ adDuration }),
|
|
42
|
+
setShowSkipButton: (showSkipButton) => set({ showSkipButton }),
|
|
43
|
+
setResumeTime: (resumeTime) => set({ resumeTime }),
|
|
44
|
+
addPendingMidRollAd: (ad) =>
|
|
45
|
+
set((state) => ({
|
|
46
|
+
pendingMidRollAds: [...state.pendingMidRollAds, ad],
|
|
47
|
+
})),
|
|
48
|
+
clearPendingMidRollAds: () => set({ pendingMidRollAds: [] }),
|
|
49
|
+
resetAdsStore: () => {
|
|
50
|
+
set(adsStoreDataDefaults);
|
|
51
|
+
adsStorage.clearAll();
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
{
|
|
55
|
+
name: 'AdsPlayerStorage',
|
|
56
|
+
storage: createJSONStorage(() => adsMmkvStorage),
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useAdsPlayerStore } from '../store/adsPlayerStore';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Reusable function to reset ad state
|
|
5
|
+
* Consolidates duplicate logic for resetting ad state across components
|
|
6
|
+
*/
|
|
7
|
+
export const resetAdState = () => {
|
|
8
|
+
try {
|
|
9
|
+
const {
|
|
10
|
+
setIsAdPlaying,
|
|
11
|
+
setCurrentAd,
|
|
12
|
+
setAdCurrentTime,
|
|
13
|
+
setAdDuration,
|
|
14
|
+
setShowSkipButton,
|
|
15
|
+
setIsAdPaused,
|
|
16
|
+
setIsAdBuffering,
|
|
17
|
+
} = useAdsPlayerStore.getState();
|
|
18
|
+
|
|
19
|
+
setIsAdPlaying(false);
|
|
20
|
+
setCurrentAd(null);
|
|
21
|
+
setAdCurrentTime(0);
|
|
22
|
+
setAdDuration(0);
|
|
23
|
+
setShowSkipButton(false);
|
|
24
|
+
setIsAdPaused(false);
|
|
25
|
+
setIsAdBuffering(false);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error('Error resetting ad state:', error);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Linking } from 'react-native';
|
|
2
|
+
import type { VideoAd } from '../../VideoPlayer/store/videoPlayer.type';
|
|
3
|
+
import { useVideoPlayerStore } from '../../VideoPlayer/store/videoPlayerStore';
|
|
4
|
+
import { useAdsPlayerStore } from '../store/adsPlayerStore';
|
|
5
|
+
import { createRef } from 'react';
|
|
6
|
+
import type { AdsPlayerRef } from '../AdsPlayer';
|
|
7
|
+
export const adVideoRef = createRef<AdsPlayerRef>();
|
|
8
|
+
|
|
9
|
+
export const getDomainFromUrl = (url: string | undefined): string => {
|
|
10
|
+
if (!url) return '';
|
|
11
|
+
const domain = url.replace(/^https?:\/\//, '').split('/')[0];
|
|
12
|
+
return domain || '';
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const handleAdClickThrough = async (
|
|
16
|
+
ad: VideoAd,
|
|
17
|
+
onAdTracking?: ({
|
|
18
|
+
ad,
|
|
19
|
+
trackingUrl,
|
|
20
|
+
event,
|
|
21
|
+
}: {
|
|
22
|
+
ad: VideoAd;
|
|
23
|
+
trackingUrl: string;
|
|
24
|
+
event: string;
|
|
25
|
+
}) => void
|
|
26
|
+
): Promise<void> => {
|
|
27
|
+
if (!ad.clickThroughUrl) return;
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const canOpen = await Linking.canOpenURL(ad.clickThroughUrl);
|
|
31
|
+
if (canOpen) {
|
|
32
|
+
await Linking.openURL(ad.clickThroughUrl);
|
|
33
|
+
if (ad.tracking?.click && onAdTracking) {
|
|
34
|
+
onAdTracking({
|
|
35
|
+
ad,
|
|
36
|
+
trackingUrl: ad.tracking.click,
|
|
37
|
+
event: 'click',
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error('Error opening ad URL:', error);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const hideAdControls = (): void => {
|
|
47
|
+
const { setControlsVisible } = useVideoPlayerStore.getState();
|
|
48
|
+
const { isAdPaused } = useAdsPlayerStore.getState();
|
|
49
|
+
if (isAdPaused) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
setControlsVisible(false);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const showAdControls = (): void => {
|
|
56
|
+
const { setControlsVisible } = useVideoPlayerStore.getState();
|
|
57
|
+
setControlsVisible(true);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const toggleAdControls = (): void => {
|
|
61
|
+
const { controlsVisible, setControlsVisible } =
|
|
62
|
+
useVideoPlayerStore.getState();
|
|
63
|
+
const { isAdPaused } = useAdsPlayerStore.getState();
|
|
64
|
+
if (isAdPaused) {
|
|
65
|
+
setControlsVisible(true);
|
|
66
|
+
} else {
|
|
67
|
+
setControlsVisible(!controlsVisible);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
import { useVideoPlayerStore } from '../../VideoPlayer/store/videoPlayerStore';
|
|
4
|
+
import { useAdsPlayerStore } from '../store/adsPlayerStore';
|
|
5
|
+
import { hideAdControls } from './controls';
|
|
6
|
+
|
|
7
|
+
export const useAdControlsAutoHide = (): Animated.Value => {
|
|
8
|
+
const { controlsVisible, controlsTimer } = useVideoPlayerStore();
|
|
9
|
+
const { isAdPaused } = useAdsPlayerStore();
|
|
10
|
+
const timeoutId = useRef<NodeJS.Timeout | null>(null);
|
|
11
|
+
const fadeAnim = useRef(new Animated.Value(0)).current;
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
Animated.timing(fadeAnim, {
|
|
15
|
+
toValue: controlsVisible ? 1 : 0,
|
|
16
|
+
duration: 200,
|
|
17
|
+
useNativeDriver: true,
|
|
18
|
+
}).start();
|
|
19
|
+
|
|
20
|
+
if (controlsVisible && !isAdPaused) {
|
|
21
|
+
timeoutId.current = setTimeout(() => {
|
|
22
|
+
hideAdControls();
|
|
23
|
+
}, controlsTimer * 1000);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return () => {
|
|
27
|
+
if (timeoutId.current) clearTimeout(timeoutId.current);
|
|
28
|
+
};
|
|
29
|
+
}, [controlsVisible, controlsTimer, fadeAnim, isAdPaused]);
|
|
30
|
+
|
|
31
|
+
return fadeAnim;
|
|
32
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useAdsPlayerStore } from '../store/adsPlayerStore';
|
|
3
|
+
import { useVideoPlayerStore } from '../../VideoPlayer/store/videoPlayerStore';
|
|
4
|
+
import { handlePause } from '../../VideoPlayer/utils';
|
|
5
|
+
import type { VideoAd } from '../../VideoPlayer/store/videoPlayer.type';
|
|
6
|
+
|
|
7
|
+
interface UseAdInitializationParams {
|
|
8
|
+
onAdTracking?: ({
|
|
9
|
+
ad,
|
|
10
|
+
trackingUrl,
|
|
11
|
+
event,
|
|
12
|
+
}: {
|
|
13
|
+
ad: VideoAd;
|
|
14
|
+
trackingUrl: string;
|
|
15
|
+
event: string;
|
|
16
|
+
}) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Reusable hook for initializing and starting ads
|
|
21
|
+
* Consolidates duplicate ad initialization logic from useAdsManager
|
|
22
|
+
*/
|
|
23
|
+
export const useAdInitialization = ({
|
|
24
|
+
onAdTracking,
|
|
25
|
+
}: UseAdInitializationParams = {}) => {
|
|
26
|
+
const { setCurrentAd, setIsAdPlaying, setIsAdPaused, setResumeTime } =
|
|
27
|
+
useAdsPlayerStore();
|
|
28
|
+
const { setIsPaused } = useVideoPlayerStore();
|
|
29
|
+
|
|
30
|
+
const startAd = useCallback(
|
|
31
|
+
(
|
|
32
|
+
ad: VideoAd,
|
|
33
|
+
options: {
|
|
34
|
+
resumeTime?: number;
|
|
35
|
+
trackImpression?: boolean;
|
|
36
|
+
} = {}
|
|
37
|
+
) => {
|
|
38
|
+
try {
|
|
39
|
+
// Always pause main video first before starting ad
|
|
40
|
+
// Use handlePause to properly pause video and save watch time
|
|
41
|
+
handlePause();
|
|
42
|
+
setIsPaused(true);
|
|
43
|
+
|
|
44
|
+
// Set ad state - ensure ad is ready to play
|
|
45
|
+
setCurrentAd(ad);
|
|
46
|
+
setIsAdPlaying(true);
|
|
47
|
+
setIsAdPaused(false);
|
|
48
|
+
|
|
49
|
+
if (options.resumeTime !== undefined) {
|
|
50
|
+
setResumeTime(options.resumeTime);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Track impression is handled in AdsPlayer component to avoid duplication
|
|
54
|
+
// Only track here if explicitly requested
|
|
55
|
+
if (
|
|
56
|
+
options.trackImpression === true &&
|
|
57
|
+
ad.tracking?.impression &&
|
|
58
|
+
onAdTracking
|
|
59
|
+
) {
|
|
60
|
+
onAdTracking({
|
|
61
|
+
ad,
|
|
62
|
+
trackingUrl: ad.tracking.impression,
|
|
63
|
+
event: 'impression',
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error('Error starting ad:', error);
|
|
68
|
+
// Reset state on error
|
|
69
|
+
setCurrentAd(null);
|
|
70
|
+
setIsAdPlaying(false);
|
|
71
|
+
setIsAdPaused(false);
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
[
|
|
76
|
+
setCurrentAd,
|
|
77
|
+
setIsAdPlaying,
|
|
78
|
+
setIsAdPaused,
|
|
79
|
+
setIsPaused,
|
|
80
|
+
setResumeTime,
|
|
81
|
+
onAdTracking,
|
|
82
|
+
]
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
return { startAd };
|
|
86
|
+
};
|