@zezosoft/zezo-ott-react-native-video-player 1.0.0 → 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 +337 -68
- 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 +5 -3
- 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 +127 -103
- 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,312 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useEffect,
|
|
3
|
+
useRef,
|
|
4
|
+
useImperativeHandle,
|
|
5
|
+
forwardRef,
|
|
6
|
+
useCallback,
|
|
7
|
+
useMemo,
|
|
8
|
+
} from 'react';
|
|
9
|
+
import { View } from 'react-native';
|
|
10
|
+
import globalStyles from '../VideoPlayer/styles/globalStyles';
|
|
11
|
+
import Video, {
|
|
12
|
+
type OnBufferData,
|
|
13
|
+
type OnLoadStartData,
|
|
14
|
+
type OnProgressData,
|
|
15
|
+
type VideoRef,
|
|
16
|
+
} from 'react-native-video';
|
|
17
|
+
import type { EdgeInsets } from 'react-native-safe-area-context';
|
|
18
|
+
import { useAdsPlayerStore } from './store/adsPlayerStore';
|
|
19
|
+
import type { VideoAd } from '../VideoPlayer/store/videoPlayer.type';
|
|
20
|
+
import { AdMediaControlsProvider } from './MediaControls';
|
|
21
|
+
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
22
|
+
import { runOnJS } from 'react-native-reanimated';
|
|
23
|
+
import { toggleAdControls, showAdControls } from './utils/controls';
|
|
24
|
+
import { resetAdState } from './utils/adStateReset';
|
|
25
|
+
import { useAdTracking } from './utils/useAdTracking';
|
|
26
|
+
|
|
27
|
+
export interface AdsPlayerProps {
|
|
28
|
+
onAdEnd: (ad: VideoAd) => void;
|
|
29
|
+
onAdSkip?: (ad: VideoAd) => void;
|
|
30
|
+
onAdError?: (error: Error, ad: VideoAd) => void;
|
|
31
|
+
onAdTracking?: ({
|
|
32
|
+
ad,
|
|
33
|
+
trackingUrl,
|
|
34
|
+
event,
|
|
35
|
+
}: {
|
|
36
|
+
ad: VideoAd;
|
|
37
|
+
trackingUrl: string;
|
|
38
|
+
event: string;
|
|
39
|
+
}) => void;
|
|
40
|
+
onClose?: () => void;
|
|
41
|
+
insets: EdgeInsets;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface AdsPlayerRef {
|
|
45
|
+
seek: (time: number) => void;
|
|
46
|
+
getCurrentTime: () => number;
|
|
47
|
+
getDuration: () => number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const AdsPlayer = forwardRef<AdsPlayerRef, AdsPlayerProps>(
|
|
51
|
+
({ onAdEnd, onAdSkip, onAdError, onAdTracking, onClose, insets }, ref) => {
|
|
52
|
+
const {
|
|
53
|
+
currentAd,
|
|
54
|
+
adDuration,
|
|
55
|
+
adCurrentTime,
|
|
56
|
+
isAdPaused,
|
|
57
|
+
isAdMuted,
|
|
58
|
+
isAdPlaying,
|
|
59
|
+
setIsAdPaused,
|
|
60
|
+
setAdCurrentTime,
|
|
61
|
+
setAdDuration,
|
|
62
|
+
setShowSkipButton,
|
|
63
|
+
setIsAdBuffering,
|
|
64
|
+
} = useAdsPlayerStore();
|
|
65
|
+
const adVideoRef = useRef<VideoRef>(null);
|
|
66
|
+
const trackedQuartilesRef = useRef({
|
|
67
|
+
firstQuartile: false,
|
|
68
|
+
midpoint: false,
|
|
69
|
+
thirdQuartile: false,
|
|
70
|
+
});
|
|
71
|
+
const trackedImpressionRef = useRef<string | null>(null);
|
|
72
|
+
const {
|
|
73
|
+
trackAdImpression,
|
|
74
|
+
trackAdStart,
|
|
75
|
+
trackAdComplete,
|
|
76
|
+
trackAdQuartile,
|
|
77
|
+
} = useAdTracking({ onAdTracking });
|
|
78
|
+
|
|
79
|
+
const trigger = useCallback(() => {
|
|
80
|
+
toggleAdControls();
|
|
81
|
+
}, []);
|
|
82
|
+
|
|
83
|
+
const tapGesture = useMemo(
|
|
84
|
+
() =>
|
|
85
|
+
Gesture.Tap()
|
|
86
|
+
.onEnd(() => {
|
|
87
|
+
runOnJS(trigger)();
|
|
88
|
+
})
|
|
89
|
+
.maxDuration(250),
|
|
90
|
+
[trigger]
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
useImperativeHandle(ref, () => ({
|
|
94
|
+
seek: (time: number) => {
|
|
95
|
+
adVideoRef.current?.seek(time);
|
|
96
|
+
},
|
|
97
|
+
getCurrentTime: () => adCurrentTime,
|
|
98
|
+
getDuration: () => adDuration,
|
|
99
|
+
}));
|
|
100
|
+
|
|
101
|
+
// Track impression only once per ad
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (
|
|
104
|
+
currentAd &&
|
|
105
|
+
isAdPlaying &&
|
|
106
|
+
trackedImpressionRef.current !== currentAd.id
|
|
107
|
+
) {
|
|
108
|
+
try {
|
|
109
|
+
trackedImpressionRef.current = currentAd.id;
|
|
110
|
+
trackAdImpression(currentAd);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.error('Error in ad impression tracking:', error);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}, [currentAd, isAdPlaying, trackAdImpression]);
|
|
116
|
+
|
|
117
|
+
// Separate effect for ensuring ad is not paused
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (currentAd && isAdPlaying) {
|
|
120
|
+
setIsAdPaused(false);
|
|
121
|
+
showAdControls();
|
|
122
|
+
}
|
|
123
|
+
}, [currentAd, isAdPlaying, setIsAdPaused]);
|
|
124
|
+
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (currentAd?.skippable) {
|
|
127
|
+
if (currentAd.skipAfter > 0) {
|
|
128
|
+
const timer = setTimeout(() => {
|
|
129
|
+
setShowSkipButton(true);
|
|
130
|
+
}, currentAd.skipAfter * 1000);
|
|
131
|
+
return () => clearTimeout(timer);
|
|
132
|
+
}
|
|
133
|
+
setShowSkipButton(true);
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
setShowSkipButton(false);
|
|
137
|
+
return undefined;
|
|
138
|
+
}, [currentAd, setShowSkipButton]);
|
|
139
|
+
|
|
140
|
+
const handleAdProgress = (data: OnProgressData) => {
|
|
141
|
+
setAdCurrentTime(data.currentTime);
|
|
142
|
+
setAdDuration(data.seekableDuration || 0);
|
|
143
|
+
|
|
144
|
+
// Reset buffering state when progress updates (playback has resumed)
|
|
145
|
+
const { isAdBuffering } = useAdsPlayerStore.getState();
|
|
146
|
+
if (isAdBuffering) {
|
|
147
|
+
setIsAdBuffering(false);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (currentAd && adDuration > 0) {
|
|
151
|
+
const progress = data.currentTime / adDuration;
|
|
152
|
+
if (progress >= 0.25 && !trackedQuartilesRef.current.firstQuartile) {
|
|
153
|
+
trackedQuartilesRef.current.firstQuartile = true;
|
|
154
|
+
trackAdQuartile(currentAd, 'firstQuartile');
|
|
155
|
+
}
|
|
156
|
+
if (progress >= 0.5 && !trackedQuartilesRef.current.midpoint) {
|
|
157
|
+
trackedQuartilesRef.current.midpoint = true;
|
|
158
|
+
trackAdQuartile(currentAd, 'midpoint');
|
|
159
|
+
}
|
|
160
|
+
if (progress >= 0.75 && !trackedQuartilesRef.current.thirdQuartile) {
|
|
161
|
+
trackedQuartilesRef.current.thirdQuartile = true;
|
|
162
|
+
trackAdQuartile(currentAd, 'thirdQuartile');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const handleAdLoadStart = (_: OnLoadStartData) => {
|
|
168
|
+
setIsAdBuffering(true);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const handleAdLoad = () => {
|
|
172
|
+
try {
|
|
173
|
+
setIsAdBuffering(false);
|
|
174
|
+
if (currentAd) {
|
|
175
|
+
setAdDuration(currentAd.duration);
|
|
176
|
+
trackAdStart(currentAd);
|
|
177
|
+
}
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.error('Error in handleAdLoad:', error);
|
|
180
|
+
if (currentAd && onAdError) {
|
|
181
|
+
onAdError(
|
|
182
|
+
error instanceof Error ? error : new Error('Ad load failed'),
|
|
183
|
+
currentAd
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const handleAdEnd = () => {
|
|
190
|
+
if (!currentAd) return;
|
|
191
|
+
|
|
192
|
+
try {
|
|
193
|
+
trackAdComplete(currentAd);
|
|
194
|
+
resetAdState();
|
|
195
|
+
trackedQuartilesRef.current = {
|
|
196
|
+
firstQuartile: false,
|
|
197
|
+
midpoint: false,
|
|
198
|
+
thirdQuartile: false,
|
|
199
|
+
};
|
|
200
|
+
// Reset impression tracking for next ad
|
|
201
|
+
trackedImpressionRef.current = null;
|
|
202
|
+
onAdEnd(currentAd);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
console.error('Error in handleAdEnd:', error);
|
|
205
|
+
resetAdState();
|
|
206
|
+
trackedImpressionRef.current = null;
|
|
207
|
+
onAdEnd(currentAd);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const handleAdError = (error: {
|
|
212
|
+
error: {
|
|
213
|
+
code?: string;
|
|
214
|
+
localizedDescription?: string;
|
|
215
|
+
errorString?: string;
|
|
216
|
+
};
|
|
217
|
+
}) => {
|
|
218
|
+
if (!currentAd) return;
|
|
219
|
+
|
|
220
|
+
try {
|
|
221
|
+
const errorMessage =
|
|
222
|
+
error.error?.localizedDescription ||
|
|
223
|
+
error.error?.errorString ||
|
|
224
|
+
'Ad playback failed';
|
|
225
|
+
console.error('Ad playback error:', errorMessage, error);
|
|
226
|
+
|
|
227
|
+
resetAdState();
|
|
228
|
+
// Reset impression tracking on error
|
|
229
|
+
trackedImpressionRef.current = null;
|
|
230
|
+
|
|
231
|
+
if (onAdError) {
|
|
232
|
+
onAdError(new Error(errorMessage), currentAd);
|
|
233
|
+
} else {
|
|
234
|
+
// Fallback: treat error as ad end
|
|
235
|
+
onAdEnd(currentAd);
|
|
236
|
+
}
|
|
237
|
+
} catch (err) {
|
|
238
|
+
console.error('Error in handleAdError:', err);
|
|
239
|
+
resetAdState();
|
|
240
|
+
trackedImpressionRef.current = null;
|
|
241
|
+
if (currentAd && onAdEnd) {
|
|
242
|
+
onAdEnd(currentAd);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
// Memoize video style for performance
|
|
248
|
+
const videoStyle = useMemo(
|
|
249
|
+
() => [
|
|
250
|
+
globalStyles.absoluteFill,
|
|
251
|
+
{
|
|
252
|
+
transform: [{ scaleX: 1.24 }, { scaleY: 1.15 }],
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
[]
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
// Memoize container style
|
|
259
|
+
const containerStyle = useMemo(
|
|
260
|
+
() => [globalStyles.absoluteFill, { backgroundColor: '#000' }],
|
|
261
|
+
[]
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
if (!currentAd || !isAdPlaying) {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return (
|
|
269
|
+
<GestureDetector gesture={tapGesture}>
|
|
270
|
+
<View style={containerStyle} collapsable={false}>
|
|
271
|
+
<AdMediaControlsProvider
|
|
272
|
+
onAdSkip={onAdSkip}
|
|
273
|
+
onAdTracking={onAdTracking}
|
|
274
|
+
onClose={onClose}
|
|
275
|
+
insets={insets}
|
|
276
|
+
>
|
|
277
|
+
<Video
|
|
278
|
+
ref={adVideoRef}
|
|
279
|
+
source={{ uri: currentAd.source }}
|
|
280
|
+
paused={isAdPaused}
|
|
281
|
+
muted={isAdMuted}
|
|
282
|
+
onProgress={handleAdProgress}
|
|
283
|
+
onLoad={handleAdLoad}
|
|
284
|
+
onEnd={handleAdEnd}
|
|
285
|
+
onError={handleAdError}
|
|
286
|
+
onBuffer={({ isBuffering }: OnBufferData) => {
|
|
287
|
+
if (isBuffering) {
|
|
288
|
+
setIsAdBuffering(true);
|
|
289
|
+
} else {
|
|
290
|
+
setTimeout(() => setIsAdBuffering(false), 150);
|
|
291
|
+
}
|
|
292
|
+
}}
|
|
293
|
+
onLoadStart={handleAdLoadStart}
|
|
294
|
+
resizeMode="contain"
|
|
295
|
+
style={videoStyle}
|
|
296
|
+
controls={false}
|
|
297
|
+
playInBackground={false}
|
|
298
|
+
playWhenInactive={false}
|
|
299
|
+
pointerEvents="box-none"
|
|
300
|
+
ignoreSilentSwitch="ignore"
|
|
301
|
+
progressUpdateInterval={250}
|
|
302
|
+
/>
|
|
303
|
+
</AdMediaControlsProvider>
|
|
304
|
+
</View>
|
|
305
|
+
</GestureDetector>
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
AdsPlayer.displayName = 'AdsPlayer';
|
|
311
|
+
|
|
312
|
+
export default AdsPlayer;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import React, { memo, useCallback, useMemo } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Animated,
|
|
4
|
+
StyleSheet,
|
|
5
|
+
Text,
|
|
6
|
+
View,
|
|
7
|
+
TouchableOpacity,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import { scale, moderateScale } from 'react-native-size-matters';
|
|
10
|
+
import { RFValue } from 'react-native-responsive-fontsize';
|
|
11
|
+
import { ExternalLink } from 'lucide-react-native';
|
|
12
|
+
import { useAdsPlayerStore } from '../store/adsPlayerStore';
|
|
13
|
+
import { useAdControls } from './AdMediaControlsProvider';
|
|
14
|
+
import { useAdControlsAutoHide } from '../utils/useAdControlsAutoHide';
|
|
15
|
+
import ProgressBar from '../../VideoPlayer/components/ProgressBar';
|
|
16
|
+
import { handleAdClickThrough } from '../utils/controls';
|
|
17
|
+
import { resetAdState } from '../utils/adStateReset';
|
|
18
|
+
import { useAdTracking } from '../utils/useAdTracking';
|
|
19
|
+
|
|
20
|
+
const AdBottomControls: React.FC = () => {
|
|
21
|
+
const currentAd = useAdsPlayerStore((state) => state.currentAd);
|
|
22
|
+
const adCurrentTime = useAdsPlayerStore((state) => state.adCurrentTime);
|
|
23
|
+
const adDuration = useAdsPlayerStore((state) => state.adDuration);
|
|
24
|
+
const { onAdSkip, onAdTracking } = useAdControls();
|
|
25
|
+
const fadeAnim = useAdControlsAutoHide();
|
|
26
|
+
const { trackAdSkip, trackAdClick } = useAdTracking({ onAdTracking });
|
|
27
|
+
|
|
28
|
+
const shouldShowSkipButton = useMemo(
|
|
29
|
+
() =>
|
|
30
|
+
currentAd?.skippable &&
|
|
31
|
+
currentAd.skipAfter > 0 &&
|
|
32
|
+
adCurrentTime >= currentAd.skipAfter,
|
|
33
|
+
[currentAd?.skippable, currentAd?.skipAfter, adCurrentTime]
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// Memoize animated style
|
|
37
|
+
const animatedOpacityStyle = useMemo(
|
|
38
|
+
() => ({ opacity: fadeAnim }),
|
|
39
|
+
[fadeAnim]
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const handleSkip = useCallback(() => {
|
|
43
|
+
if (!currentAd) return;
|
|
44
|
+
|
|
45
|
+
trackAdSkip(currentAd);
|
|
46
|
+
onAdSkip?.(currentAd);
|
|
47
|
+
resetAdState();
|
|
48
|
+
}, [currentAd, onAdSkip, trackAdSkip]);
|
|
49
|
+
|
|
50
|
+
const handleClickThrough = useCallback(() => {
|
|
51
|
+
if (currentAd) {
|
|
52
|
+
trackAdClick(currentAd);
|
|
53
|
+
handleAdClickThrough(currentAd, onAdTracking);
|
|
54
|
+
}
|
|
55
|
+
}, [currentAd, onAdTracking, trackAdClick]);
|
|
56
|
+
|
|
57
|
+
if (!currentAd) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<View style={bottomControlsStyles.container}>
|
|
63
|
+
{/* Ad Metadata */}
|
|
64
|
+
{currentAd.clickThroughUrl && (
|
|
65
|
+
<Animated.View style={animatedOpacityStyle} pointerEvents="box-none">
|
|
66
|
+
<View pointerEvents="auto">
|
|
67
|
+
<TouchableOpacity
|
|
68
|
+
style={bottomControlsStyles.metadataContainer}
|
|
69
|
+
onPress={handleClickThrough}
|
|
70
|
+
activeOpacity={0.7}
|
|
71
|
+
>
|
|
72
|
+
<View style={bottomControlsStyles.metadataContent}>
|
|
73
|
+
<View style={bottomControlsStyles.metadataTextContainer}>
|
|
74
|
+
{currentAd.title && (
|
|
75
|
+
<Text
|
|
76
|
+
style={bottomControlsStyles.metadataTitle}
|
|
77
|
+
numberOfLines={1}
|
|
78
|
+
ellipsizeMode="tail"
|
|
79
|
+
>
|
|
80
|
+
{currentAd.title}
|
|
81
|
+
</Text>
|
|
82
|
+
)}
|
|
83
|
+
{currentAd.description && (
|
|
84
|
+
<Text
|
|
85
|
+
style={bottomControlsStyles.metadataDesc}
|
|
86
|
+
numberOfLines={2}
|
|
87
|
+
ellipsizeMode="tail"
|
|
88
|
+
>
|
|
89
|
+
{currentAd.description}
|
|
90
|
+
</Text>
|
|
91
|
+
)}
|
|
92
|
+
</View>
|
|
93
|
+
<View style={bottomControlsStyles.clickIndicator}>
|
|
94
|
+
<ExternalLink size={scale(14)} color="#fff" />
|
|
95
|
+
</View>
|
|
96
|
+
</View>
|
|
97
|
+
</TouchableOpacity>
|
|
98
|
+
</View>
|
|
99
|
+
</Animated.View>
|
|
100
|
+
)}
|
|
101
|
+
|
|
102
|
+
<Animated.View style={animatedOpacityStyle}>
|
|
103
|
+
<ProgressBar
|
|
104
|
+
duration={adDuration}
|
|
105
|
+
currentTime={adCurrentTime}
|
|
106
|
+
bufferedTime={adDuration}
|
|
107
|
+
disabled={true}
|
|
108
|
+
height={moderateScale(3)}
|
|
109
|
+
/>
|
|
110
|
+
</Animated.View>
|
|
111
|
+
{shouldShowSkipButton && (
|
|
112
|
+
<View pointerEvents="auto">
|
|
113
|
+
<TouchableOpacity
|
|
114
|
+
onPress={handleSkip}
|
|
115
|
+
style={bottomControlsStyles.skipButton}
|
|
116
|
+
activeOpacity={0.7}
|
|
117
|
+
>
|
|
118
|
+
<Text style={bottomControlsStyles.skipButtonText}>Skip Ad</Text>
|
|
119
|
+
</TouchableOpacity>
|
|
120
|
+
</View>
|
|
121
|
+
)}
|
|
122
|
+
</View>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const bottomControlsStyles = StyleSheet.create({
|
|
127
|
+
container: {
|
|
128
|
+
position: 'relative',
|
|
129
|
+
bottom: 0,
|
|
130
|
+
zIndex: 1,
|
|
131
|
+
},
|
|
132
|
+
metadataContainer: {
|
|
133
|
+
backgroundColor: 'rgba(21, 21, 21, 0.95)',
|
|
134
|
+
borderRadius: moderateScale(6),
|
|
135
|
+
overflow: 'hidden',
|
|
136
|
+
marginBottom: moderateScale(5),
|
|
137
|
+
maxWidth: moderateScale(200),
|
|
138
|
+
borderWidth: 1,
|
|
139
|
+
borderColor: 'rgba(174, 174, 174, 0.12)',
|
|
140
|
+
},
|
|
141
|
+
metadataContent: {
|
|
142
|
+
flexDirection: 'row',
|
|
143
|
+
alignItems: 'center',
|
|
144
|
+
padding: moderateScale(5),
|
|
145
|
+
},
|
|
146
|
+
metadataTextContainer: {
|
|
147
|
+
flex: 1,
|
|
148
|
+
marginRight: moderateScale(4),
|
|
149
|
+
minWidth: 0,
|
|
150
|
+
},
|
|
151
|
+
metadataTitle: {
|
|
152
|
+
color: '#FFFFFF',
|
|
153
|
+
fontSize: RFValue(10),
|
|
154
|
+
fontWeight: '400',
|
|
155
|
+
marginBottom: moderateScale(0.5),
|
|
156
|
+
letterSpacing: 0.1,
|
|
157
|
+
},
|
|
158
|
+
metadataDesc: {
|
|
159
|
+
color: 'rgba(255, 255, 255, 0.7)',
|
|
160
|
+
fontSize: RFValue(9),
|
|
161
|
+
lineHeight: RFValue(12),
|
|
162
|
+
},
|
|
163
|
+
clickIndicator: {
|
|
164
|
+
width: moderateScale(20),
|
|
165
|
+
height: moderateScale(20),
|
|
166
|
+
borderRadius: moderateScale(10),
|
|
167
|
+
backgroundColor: 'rgba(255, 255, 255, 0.20)',
|
|
168
|
+
justifyContent: 'center',
|
|
169
|
+
alignItems: 'center',
|
|
170
|
+
},
|
|
171
|
+
skipButton: {
|
|
172
|
+
position: 'absolute',
|
|
173
|
+
right: moderateScale(2),
|
|
174
|
+
bottom: moderateScale(25),
|
|
175
|
+
backgroundColor: 'rgba(21, 21, 21, 0.95)',
|
|
176
|
+
paddingHorizontal: moderateScale(15),
|
|
177
|
+
paddingVertical: moderateScale(7),
|
|
178
|
+
borderRadius: moderateScale(14),
|
|
179
|
+
borderWidth: 1,
|
|
180
|
+
borderColor: 'rgba(255, 255, 255, 0.20)',
|
|
181
|
+
},
|
|
182
|
+
skipButtonText: {
|
|
183
|
+
color: '#fff',
|
|
184
|
+
fontSize: RFValue(12),
|
|
185
|
+
fontWeight: '600',
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
export default memo(AdBottomControls);
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { memo, useMemo } from 'react';
|
|
2
|
+
import { Animated, StyleSheet, View, type ViewStyle } from 'react-native';
|
|
3
|
+
import LinearGradient from 'react-native-linear-gradient';
|
|
4
|
+
import { moderateScale } from 'react-native-size-matters';
|
|
5
|
+
import type { EdgeInsets } from 'react-native-safe-area-context';
|
|
6
|
+
import { useAdControlsAutoHide } from '../utils/useAdControlsAutoHide';
|
|
7
|
+
import AdTopControls from './AdTopControls';
|
|
8
|
+
import AdMiddleControls from './AdMiddleControls';
|
|
9
|
+
import AdBottomControls from './AdBottomControls';
|
|
10
|
+
import globalStyles from '../../VideoPlayer/styles/globalStyles';
|
|
11
|
+
|
|
12
|
+
interface AdMediaControlsProps {
|
|
13
|
+
onClose?: () => void;
|
|
14
|
+
insets: EdgeInsets;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const AdMediaControls: React.FC<AdMediaControlsProps> = ({
|
|
18
|
+
onClose,
|
|
19
|
+
insets,
|
|
20
|
+
}) => {
|
|
21
|
+
const { top, bottom, left, right } = insets;
|
|
22
|
+
const fadeAnim = useAdControlsAutoHide();
|
|
23
|
+
|
|
24
|
+
// Memoize container style to avoid recalculation
|
|
25
|
+
const containerStyle: ViewStyle = useMemo(
|
|
26
|
+
() => ({
|
|
27
|
+
...styles.container,
|
|
28
|
+
paddingTop: top,
|
|
29
|
+
paddingBottom: bottom - moderateScale(5),
|
|
30
|
+
paddingLeft: left + moderateScale(15),
|
|
31
|
+
paddingRight: right + moderateScale(15),
|
|
32
|
+
}),
|
|
33
|
+
[top, bottom, left, right]
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// Memoize gradient overlay styles
|
|
37
|
+
const topGradientStyle = useMemo(
|
|
38
|
+
() => [styles.topGradientOverlay, { opacity: fadeAnim, top: -top }],
|
|
39
|
+
[fadeAnim, top]
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const bottomGradientStyle = useMemo(
|
|
43
|
+
() => [
|
|
44
|
+
styles.bottomGradientOverlay,
|
|
45
|
+
{ opacity: fadeAnim, bottom: -(bottom - moderateScale(5)) },
|
|
46
|
+
],
|
|
47
|
+
[fadeAnim, bottom]
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
<Animated.View style={topGradientStyle} pointerEvents="none">
|
|
53
|
+
<LinearGradient
|
|
54
|
+
colors={['rgba(0, 0, 0, 0.4)', 'transparent', 'transparent']}
|
|
55
|
+
locations={[0, 0.4, 1]}
|
|
56
|
+
style={globalStyles.absoluteFill}
|
|
57
|
+
pointerEvents="none"
|
|
58
|
+
/>
|
|
59
|
+
</Animated.View>
|
|
60
|
+
<View style={containerStyle}>
|
|
61
|
+
<AdTopControls onClose={onClose} />
|
|
62
|
+
<AdMiddleControls />
|
|
63
|
+
<AdBottomControls />
|
|
64
|
+
</View>
|
|
65
|
+
<Animated.View style={bottomGradientStyle} pointerEvents="none">
|
|
66
|
+
<LinearGradient
|
|
67
|
+
colors={['transparent', 'transparent', 'rgba(0, 0, 0, 0.5)']}
|
|
68
|
+
locations={[0, 0.4, 1]}
|
|
69
|
+
style={globalStyles.absoluteFill}
|
|
70
|
+
pointerEvents="none"
|
|
71
|
+
/>
|
|
72
|
+
</Animated.View>
|
|
73
|
+
</>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export default memo(AdMediaControls);
|
|
78
|
+
|
|
79
|
+
const styles = StyleSheet.create({
|
|
80
|
+
container: {
|
|
81
|
+
...globalStyles.absoluteFill,
|
|
82
|
+
justifyContent: 'space-between',
|
|
83
|
+
},
|
|
84
|
+
topGradientOverlay: {
|
|
85
|
+
position: 'absolute',
|
|
86
|
+
left: 0,
|
|
87
|
+
right: 0,
|
|
88
|
+
height: moderateScale(150),
|
|
89
|
+
zIndex: 0,
|
|
90
|
+
},
|
|
91
|
+
bottomGradientOverlay: {
|
|
92
|
+
position: 'absolute',
|
|
93
|
+
left: 0,
|
|
94
|
+
right: 0,
|
|
95
|
+
height: moderateScale(150),
|
|
96
|
+
zIndex: 0,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React, { createContext, useContext } from 'react';
|
|
2
|
+
import type { EdgeInsets } from 'react-native-safe-area-context';
|
|
3
|
+
|
|
4
|
+
import { useAdsPlayerStore } from '../store/adsPlayerStore';
|
|
5
|
+
import type { VideoAd } from '../../VideoPlayer/store/videoPlayer.type';
|
|
6
|
+
import AdMediaControls from './AdMediaControls';
|
|
7
|
+
|
|
8
|
+
interface AdControlsContextType {
|
|
9
|
+
onAdSkip?: (ad: VideoAd) => void;
|
|
10
|
+
onAdTracking?: ({
|
|
11
|
+
ad,
|
|
12
|
+
trackingUrl,
|
|
13
|
+
event,
|
|
14
|
+
}: {
|
|
15
|
+
ad: VideoAd;
|
|
16
|
+
trackingUrl: string;
|
|
17
|
+
event: string;
|
|
18
|
+
}) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const AdControlsContext = createContext<AdControlsContextType>({});
|
|
22
|
+
|
|
23
|
+
export const useAdControls = () => useContext(AdControlsContext);
|
|
24
|
+
|
|
25
|
+
interface AdMediaControlsProviderProps {
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
onAdSkip?: (ad: VideoAd) => void;
|
|
28
|
+
onAdTracking?: ({
|
|
29
|
+
ad,
|
|
30
|
+
trackingUrl,
|
|
31
|
+
event,
|
|
32
|
+
}: {
|
|
33
|
+
ad: VideoAd;
|
|
34
|
+
trackingUrl: string;
|
|
35
|
+
event: string;
|
|
36
|
+
}) => void;
|
|
37
|
+
onClose?: () => void;
|
|
38
|
+
insets: EdgeInsets;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const AdMediaControlsProvider: React.FC<AdMediaControlsProviderProps> = ({
|
|
42
|
+
children,
|
|
43
|
+
onAdSkip,
|
|
44
|
+
onAdTracking,
|
|
45
|
+
onClose,
|
|
46
|
+
insets,
|
|
47
|
+
}) => {
|
|
48
|
+
const isAdPlaying = useAdsPlayerStore((state) => state.isAdPlaying);
|
|
49
|
+
|
|
50
|
+
if (!isAdPlaying) {
|
|
51
|
+
return <>{children}</>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<AdControlsContext.Provider value={{ onAdSkip, onAdTracking }}>
|
|
56
|
+
{children}
|
|
57
|
+
<AdMediaControls onClose={onClose} insets={insets} />
|
|
58
|
+
</AdControlsContext.Provider>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default AdMediaControlsProvider;
|