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

63 lines (62 loc) 1.66 kB
"use strict"; import { Linking } from 'react-native'; import { useVideoPlayerStore } from "../../VideoPlayer/store/videoPlayerStore.js"; import { useAdsPlayerStore } from "../store/adsPlayerStore.js"; import { createRef } from 'react'; export const adVideoRef = /*#__PURE__*/createRef(); export const getDomainFromUrl = url => { if (!url) return ''; const domain = url.replace(/^https?:\/\//, '').split('/')[0]; return domain || ''; }; export const handleAdClickThrough = async (ad, onAdTracking) => { if (!ad.clickThroughUrl) return; try { const canOpen = await Linking.canOpenURL(ad.clickThroughUrl); if (canOpen) { await Linking.openURL(ad.clickThroughUrl); if (ad.tracking?.click && onAdTracking) { onAdTracking({ ad, trackingUrl: ad.tracking.click, event: 'click' }); } } } catch (error) { console.error('Error opening ad URL:', error); } }; export const hideAdControls = () => { const { setControlsVisible } = useVideoPlayerStore.getState(); const { isAdPaused } = useAdsPlayerStore.getState(); if (isAdPaused) { return; } setControlsVisible(false); }; export const showAdControls = () => { const { setControlsVisible } = useVideoPlayerStore.getState(); setControlsVisible(true); }; export const toggleAdControls = () => { const { controlsVisible, setControlsVisible } = useVideoPlayerStore.getState(); const { isAdPaused } = useAdsPlayerStore.getState(); if (isAdPaused) { setControlsVisible(true); } else { setControlsVisible(!controlsVisible); } }; //# sourceMappingURL=controls.js.map