UNPKG

@zezosoft/zezo-ott-react-native-video-player

Version:

Production-ready React Native OTT video player library for Android & iOS. Features: playlists, seasons, auto-next playback, subtitles (SRT/VTT), custom theming, analytics tracking, fullscreen mode, gesture controls, ads player (pre-roll/mid-roll/post-roll

35 lines (34 loc) 1.09 kB
"use strict"; import { useEffect, useRef } from 'react'; import { Animated } from 'react-native'; import { useVideoPlayerStore } from "../../VideoPlayer/store/videoPlayerStore.js"; import { useAdsPlayerStore } from "../store/adsPlayerStore.js"; import { hideAdControls } from "./controls.js"; export const useAdControlsAutoHide = () => { const { controlsVisible, controlsTimer } = useVideoPlayerStore(); const { isAdPaused } = useAdsPlayerStore(); const timeoutId = useRef(null); const fadeAnim = useRef(new Animated.Value(0)).current; useEffect(() => { Animated.timing(fadeAnim, { toValue: controlsVisible ? 1 : 0, duration: 200, useNativeDriver: true }).start(); if (controlsVisible && !isAdPaused) { timeoutId.current = setTimeout(() => { hideAdControls(); }, controlsTimer * 1000); } return () => { if (timeoutId.current) clearTimeout(timeoutId.current); }; }, [controlsVisible, controlsTimer, fadeAnim, isAdPaused]); return fadeAnim; }; //# sourceMappingURL=useAdControlsAutoHide.js.map