@zuude-ui/video 0.1.42 → 0.1.55
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/dist/chunk-3LYIWCZO.js +2 -0
- package/dist/chunk-3LYIWCZO.js.map +1 -0
- package/dist/chunk-4OJ2XRGY.js +2 -0
- package/dist/chunk-4OJ2XRGY.js.map +1 -0
- package/dist/chunk-72XT2CEM.js +2 -0
- package/dist/chunk-72XT2CEM.js.map +1 -0
- package/dist/chunk-CS4V77B7.js +2 -0
- package/dist/chunk-CS4V77B7.js.map +1 -0
- package/dist/chunk-DNOJGU7F.js +2 -0
- package/dist/chunk-DNOJGU7F.js.map +1 -0
- package/dist/chunk-HEGM5TXH.js +2 -0
- package/dist/chunk-HEGM5TXH.js.map +1 -0
- package/dist/chunk-IDFSOQOU.js +2 -0
- package/dist/chunk-IDFSOQOU.js.map +1 -0
- package/dist/chunk-IQERDY45.js +2 -0
- package/dist/chunk-IQERDY45.js.map +1 -0
- package/dist/chunk-IVHP55KV.js +2 -0
- package/dist/chunk-IVHP55KV.js.map +1 -0
- package/dist/chunk-KM2LHTEJ.js +2 -0
- package/dist/chunk-KM2LHTEJ.js.map +1 -0
- package/dist/chunk-MOMKLUXO.js +2 -0
- package/dist/chunk-MOMKLUXO.js.map +1 -0
- package/dist/chunk-NPGT4WCI.js +2 -0
- package/dist/chunk-NPGT4WCI.js.map +1 -0
- package/dist/chunk-OUDZZUOB.js +2 -0
- package/dist/chunk-OUDZZUOB.js.map +1 -0
- package/dist/chunk-R372EZNW.js +2 -0
- package/dist/chunk-R372EZNW.js.map +1 -0
- package/dist/chunk-UKR5BP5U.js +2 -0
- package/dist/chunk-UKR5BP5U.js.map +1 -0
- package/dist/chunk-W6DLY3AO.js +2 -0
- package/dist/chunk-W6DLY3AO.js.map +1 -0
- package/dist/chunk-WOVLVPBO.js +2 -0
- package/dist/chunk-WOVLVPBO.js.map +1 -0
- package/dist/chunk-WY6YHDWT.js +2 -0
- package/dist/chunk-WY6YHDWT.js.map +1 -0
- package/dist/chunk-YID6OIKP.js +2 -0
- package/dist/chunk-YID6OIKP.js.map +1 -0
- package/dist/chunk-ZDOBNBGL.js +2 -0
- package/dist/chunk-ZDOBNBGL.js.map +1 -0
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-autoplay-by-force.tsx","../src/hooks/use-autoplay-on-visible.tsx","../src/hooks/use-fullscreen.tsx","../src/hooks/use-get-duration.tsx","../src/hooks/use-hot-keys.tsx","../src/hooks/use-mute-unmute.tsx","../src/hooks/use-picture-in-picture.tsx","../src/hooks/use-play-pause.tsx","../src/hooks/use-seek.tsx","../src/hooks/use-speed.tsx","../src/hooks/use-start-at.tsx","../src/hooks/use-current-time.tsx","../src/hooks/use-video-state.tsx","../src/hooks/use-volume.tsx","../src/hooks/use-buffer.tsx","../src/hooks/use-download.tsx","../src/hooks/use-range.tsx"],"sourcesContent":["import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useAutoplayByForce = (\n videoRef: VideoRef,\n enabled: boolean,\n setError?: (error: string | null) => void\n) => {\n React.useEffect(() => {\n if (!videoRef?.current || !enabled) return;\n\n const playVideo = async () => {\n try {\n await videoRef.current?.play();\n } catch (error) {\n // If autoplay fails, try muting and playing again\n if (error instanceof Error && error.name === \"NotAllowedError\") {\n setError?.(\"NotAllowedError\");\n console.error(\"NotAllowedError\");\n if (videoRef?.current) {\n videoRef.current.muted = true;\n try {\n await videoRef.current.play();\n } catch (retryError) {\n console.error(retryError);\n }\n }\n } else {\n console.error(error);\n }\n }\n };\n\n playVideo();\n }, [enabled, videoRef?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useAutoplayOnVisible = (\n videoRef: VideoRef,\n threshold: number | undefined,\n enabled = true\n) => {\n React.useEffect(() => {\n if (!videoRef?.current || !enabled) return;\n\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (!videoRef?.current) return;\n\n if (entry.isIntersecting) {\n videoRef.current.play().catch((error) => {\n if (!videoRef.current) return;\n\n videoRef.current.pause();\n videoRef.current.muted = true;\n videoRef.current.play();\n console.error(error);\n });\n } else {\n videoRef.current?.pause();\n }\n });\n },\n { threshold: threshold ?? 0.5 }\n );\n\n observer.observe(videoRef?.current);\n\n return () => {\n observer.disconnect();\n };\n }, [videoRef?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nconst useFullscreen = (videoRef: VideoRef) => {\n const [isFullscreen, setIsFullscreen] = React.useState(false);\n const previousStylesRef = React.useRef<{\n objectFit: string;\n borderRadius: string;\n width: string;\n height: string;\n maxWidth: string;\n maxHeight: string;\n margin: string;\n } | null>(null);\n console.log(\"storing previous styles\", previousStylesRef.current);\n\n React.useEffect(() => {\n const video = videoRef?.current;\n if (!video) return;\n\n const videoContainer = video.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement | null;\n\n // Helper to get fullscreen element with vendor prefix support\n const getFullscreenElement = (): Element | null => {\n return (\n document.fullscreenElement ||\n (document as any).webkitFullscreenElement ||\n (document as any).mozFullScreenElement ||\n (document as any).msFullscreenElement ||\n null\n );\n };\n\n const checkFullscreenState = () => {\n // Check if the container element is the fullscreen element\n const fullscreenElement = getFullscreenElement();\n const isCurrentlyFullscreen =\n !!fullscreenElement &&\n (fullscreenElement === videoContainer || fullscreenElement === video);\n\n setIsFullscreen(isCurrentlyFullscreen);\n\n // Apply styles based on fullscreen state\n if (video) {\n console.log({ isCurrentlyFullscreen });\n if (isCurrentlyFullscreen) {\n // Store previous styles before entering fullscreen (only if not already stored)\n if (!previousStylesRef.current) {\n previousStylesRef.current = {\n objectFit: video.style.objectFit || \"\",\n borderRadius: video.style.borderRadius || \"\",\n width: video.style.width || \"\",\n height: video.style.height || \"\",\n maxWidth: video.style.maxWidth || \"\",\n maxHeight: video.style.maxHeight || \"\",\n margin: video.style.margin || \"\",\n };\n }\n // Apply fullscreen styles\n video.style.objectFit = \"contain\";\n video.style.borderRadius = \"0\";\n video.style.width = \"100%\";\n video.style.height = \"100%\";\n video.style.maxWidth = \"none\";\n video.style.maxHeight = \"none\";\n video.style.margin = \"0\";\n } else {\n // Restore previous styles when exiting fullscreen\n if (previousStylesRef.current) {\n video.style.objectFit = previousStylesRef.current.objectFit;\n video.style.borderRadius = previousStylesRef.current.borderRadius;\n video.style.width = previousStylesRef.current.width;\n video.style.height = previousStylesRef.current.height;\n video.style.maxWidth = previousStylesRef.current.maxWidth;\n video.style.maxHeight = previousStylesRef.current.maxHeight;\n video.style.margin = previousStylesRef.current.margin;\n previousStylesRef.current = null;\n }\n }\n }\n };\n\n // Check initial state\n checkFullscreenState();\n\n // Listen for fullscreen changes\n document.addEventListener(\"fullscreenchange\", checkFullscreenState);\n\n // Also listen for vendor-prefixed events for better browser support\n document.addEventListener(\"webkitfullscreenchange\", checkFullscreenState);\n document.addEventListener(\"mozfullscreenchange\", checkFullscreenState);\n document.addEventListener(\"MSFullscreenChange\", checkFullscreenState);\n\n return () => {\n document.removeEventListener(\"fullscreenchange\", checkFullscreenState);\n document.removeEventListener(\n \"webkitfullscreenchange\",\n checkFullscreenState\n );\n document.removeEventListener(\"mozfullscreenchange\", checkFullscreenState);\n document.removeEventListener(\"MSFullscreenChange\", checkFullscreenState);\n };\n }, [videoRef]);\n\n const toggleFullscreen = () => {\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n const video = videoRef?.current;\n\n if (video && isSafari) {\n if ((video as any).webkitEnterFullscreen) {\n (video as any).webkitEnterFullscreen();\n return;\n } else if (video.requestFullscreen) {\n video.requestFullscreen();\n return;\n }\n }\n\n const videoContainer = video?.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement;\n\n if (videoContainer) {\n if (!isFullscreen) {\n videoContainer.requestFullscreen();\n } else {\n document.exitFullscreen();\n }\n }\n };\n\n return { isFullscreen: isFullscreen ?? false, toggleFullscreen };\n};\n\nexport { useFullscreen };\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useGetDuration = (videoRef: VideoRef) => {\n const [isLoading, setIsLoading] = React.useState(false);\n const [duration, setDuration] = React.useState<number | null>(null);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n setIsLoading(true);\n\n const getDuration = () => {\n setDuration(videoRef.current?.duration ?? null);\n setIsLoading(false);\n };\n\n const handleError = () => {\n setIsLoading(false);\n };\n\n const video = videoRef.current;\n\n // Check if duration is already available\n if (video.duration && !isNaN(video.duration)) {\n setDuration(video.duration);\n setIsLoading(false);\n } else {\n // Add event listeners\n video.addEventListener(\"loadedmetadata\", getDuration);\n video.addEventListener(\"error\", handleError);\n video.addEventListener(\"loadeddata\", getDuration);\n\n return () => {\n video.removeEventListener(\"loadedmetadata\", getDuration);\n video.removeEventListener(\"error\", handleError);\n video.removeEventListener(\"loadeddata\", getDuration);\n };\n }\n }, [videoRef]);\n\n return { duration, isLoading };\n};\n","import { useEffect } from \"react\";\n\nexport const useHotKeys = (\n key: string,\n func: (event: KeyboardEvent) => void,\n enabled = true\n) => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === key) {\n event.preventDefault();\n func(event);\n }\n };\n\n useEffect(() => {\n if (!enabled) return;\n\n document.addEventListener(\"keydown\", handleKeyDown);\n\n return () => {\n document.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [key, func, enabled]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useMuteUnmute = (videoRef: VideoRef) => {\n const [isMuted, setIsMuted] = React.useState(false);\n\n const toggleMute = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = !videoRef.current.muted;\n }\n }, [videoRef?.current]);\n\n const mute = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = true;\n }\n }, [videoRef?.current]);\n\n const unmute = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = false;\n }\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n // Set the initial state\n setIsMuted(videoRef.current.muted);\n\n const handleVolumeChange = () => {\n if (videoRef.current) {\n setIsMuted(videoRef.current.muted);\n }\n };\n\n videoRef.current.addEventListener(\"volumechange\", handleVolumeChange);\n\n return () => {\n videoRef.current?.removeEventListener(\"volumechange\", handleVolumeChange);\n };\n }, [videoRef?.current]);\n\n return { toggleMute, isMuted, mute, unmute };\n};\n","import type { VideoRef } from \"../types\";\n\nexport const usePictureInPicture = (videoRef: VideoRef) => {\n const togglePictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n\n try {\n if (document.pictureInPictureElement) {\n await document.exitPictureInPicture();\n } else {\n await video.requestPictureInPicture();\n }\n } catch (error) {\n // Fallback for browsers that don't support PiP\n const isSafari = /^((?!chrome|android).)*safari/i.test(\n navigator.userAgent\n );\n\n if (isSafari) {\n if ((video as any).webkitEnterFullscreen) {\n (video as any).webkitEnterFullscreen();\n } else if (video.requestFullscreen) {\n video.requestFullscreen();\n }\n } else {\n const videoContainer = video.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement;\n if (videoContainer) {\n if (!document.fullscreenElement) {\n await videoContainer.requestFullscreen();\n } else {\n await document.exitFullscreen();\n }\n }\n }\n }\n };\n\n const requestPictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n await video.requestPictureInPicture();\n };\n\n const exitPictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n await document.exitPictureInPicture();\n };\n\n return {\n togglePictureInPicture,\n requestPictureInPicture,\n exitPictureInPicture,\n };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const usePlayPause = (videoRef: VideoRef) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n\n const togglePlay = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.paused\n ? videoRef.current.play()\n : videoRef.current.pause();\n }\n }, [videoRef?.current]);\n\n const play = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.play();\n }\n }, [videoRef?.current]);\n\n const pause = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.pause();\n }\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n const handlePlay = () => {\n setIsPlaying(true);\n };\n const handlePause = () => {\n setIsPlaying(false);\n };\n\n setIsPlaying(!videoRef?.current.paused);\n\n if (videoRef?.current) {\n videoRef.current.addEventListener(\"play\", handlePlay);\n videoRef.current.addEventListener(\"pause\", handlePause);\n\n return () => {\n videoRef.current?.removeEventListener(\"play\", handlePlay);\n videoRef.current?.removeEventListener(\"pause\", handlePause);\n };\n }\n }, [videoRef?.current]);\n\n return { togglePlay, isPlaying, play, pause };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useSeek = (videoRef: VideoRef, value = 10) => {\n const seekForward = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.currentTime += value;\n }\n }, [videoRef?.current]);\n\n const seekBackward = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.currentTime -= value;\n }\n }, [videoRef?.current]);\n\n return { seekForward, seekBackward };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useSpeed = (videoRef: VideoRef) => {\n const [speed, setSpeed] = React.useState(1);\n\n const onChangeSpeed = (speed: number) => {\n setSpeed(speed);\n };\n\n // Get the speed from the video element\n React.useEffect(() => {\n if (!videoRef?.current) return;\n setSpeed(videoRef.current.playbackRate);\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.playbackRate = speed;\n }, [speed, videoRef?.current]);\n\n return { speed, onChangeSpeed };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useStartAt = (videoRef: VideoRef, startAt: number) => {\n React.useEffect(() => {\n if (!videoRef?.current || !startAt) return;\n\n const video = videoRef?.current;\n if (video && startAt) {\n video.currentTime = startAt;\n }\n }, [startAt, videoRef?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types.js\";\n\nexport const useCurrentTime = (videoRef: VideoRef, interval = 10) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n const [currentTime, setCurrentTime] = React.useState(0);\n\n React.useEffect(() => {\n if (videoRef?.current && isPlaying) {\n const intervalId = setInterval(() => {\n setCurrentTime(videoRef.current?.currentTime || 0);\n }, interval);\n\n return () => clearInterval(intervalId);\n }\n }, [videoRef?.current, isPlaying]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n const video = videoRef.current;\n\n // Store handlers in variables for proper cleanup (critical for Safari memory safety)\n const handlePlay = () => setIsPlaying(true);\n const handlePause = () => setIsPlaying(false);\n\n video.addEventListener(\"play\", handlePlay);\n video.addEventListener(\"pause\", handlePause);\n\n return () => {\n video.removeEventListener(\"play\", handlePlay);\n video.removeEventListener(\"pause\", handlePause);\n };\n }, [videoRef?.current]);\n\n const onTimeUpdate = (time: number) => {\n if (videoRef?.current) {\n setCurrentTime(time);\n videoRef.current.currentTime = time;\n }\n };\n\n return {\n currentTime,\n onTimeUpdate,\n };\n};\n","import { RefObject, useEffect, useState } from \"react\";\n\nconst useVideoState = (videoRef: RefObject<HTMLVideoElement | null>) => {\n const [isPlaying, setIsPlaying] = useState(false);\n const [isMuted, setIsMuted] = useState(false);\n const [isFullscreen, setIsFullscreen] = useState(false);\n\n useEffect(() => {\n const video = videoRef.current;\n\n if (video) {\n video.addEventListener(\"play\", () => setIsPlaying(true));\n video.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n video.removeEventListener(\"play\", () => setIsPlaying(true));\n video.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }\n }, [videoRef]);\n\n useEffect(() => {\n if (!videoRef?.current) return;\n\n // Set the initial state\n setIsMuted(videoRef.current.muted);\n\n const handleVolumeChange = () => {\n if (videoRef.current) {\n setIsMuted(videoRef.current.muted);\n }\n };\n\n videoRef.current.addEventListener(\"volumechange\", handleVolumeChange);\n\n return () => {\n videoRef.current?.removeEventListener(\"volumechange\", handleVolumeChange);\n };\n }, [videoRef]);\n\n useEffect(() => {\n if (!videoRef?.current) return;\n\n const handleFullscreenChange = () => {\n setIsFullscreen(!!document.fullscreenElement);\n };\n\n document.addEventListener(\"fullscreenchange\", handleFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", handleFullscreenChange);\n }, [videoRef]);\n\n return { isPlaying, isMuted, isFullscreen };\n};\n\nexport { useVideoState };\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useVolume = (videoRef: VideoRef, initialVolume = 100) => {\n const [volume, setVolume] = React.useState(initialVolume);\n\n const onChangeVolume = (volume: number) => {\n setVolume(volume);\n };\n\n // Get the volume from the video element\n React.useEffect(() => {\n if (!videoRef?.current) return;\n setVolume(videoRef.current.volume * 100);\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.volume = volume / 100;\n }, [volume, videoRef?.current]);\n\n return { volume, onChangeVolume };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types.js\";\n\nexport const useBuffer = (videoRef: VideoRef, duration?: number) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n const [buffered, setBuffered] = React.useState(0);\n\n React.useEffect(() => {\n if (videoRef?.current && isPlaying) {\n const intervalId = setInterval(() => {\n if (videoRef.current?.buffered.length) {\n setBuffered(\n videoRef.current.buffered.end(videoRef.current.buffered.length - 1)\n );\n }\n }, 10);\n\n return () => clearInterval(intervalId);\n }\n }, [videoRef?.current, isPlaying]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.addEventListener(\"play\", () => setIsPlaying(true));\n videoRef.current.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n videoRef.current?.removeEventListener(\"play\", () => setIsPlaying(true));\n videoRef.current?.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }, []);\n\n return {\n buffered,\n bufferedPercentage: (buffered / (duration || 0)) * 100 || 0,\n };\n};\n","import { useEffect, useState, useCallback } from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useDownload = (videoRef: VideoRef) => {\n const [isDownloading, setIsDownloading] = useState(false);\n const [downloadProgress, setDownloadProgress] = useState(0);\n const [error, setError] = useState<string | null>(null);\n\n const downloadVideo = useCallback(\n async (filename?: string) => {\n if (!videoRef?.current) {\n setError(\"Video element not found\");\n return;\n }\n\n const video = videoRef.current;\n const videoSrc = video.src || video.currentSrc;\n\n if (!videoSrc) {\n setError(\"No video source found\");\n return;\n }\n\n try {\n setIsDownloading(true);\n setError(null);\n setDownloadProgress(0);\n\n // Fetch the video file\n const response = await fetch(videoSrc);\n\n if (!response.ok) {\n throw new Error(`Failed to fetch video: ${response.statusText}`);\n }\n\n // Get the content length for progress tracking\n const contentLength = response.headers.get(\"content-length\");\n const total = contentLength ? parseInt(contentLength, 10) : 0;\n\n // Create a readable stream to track progress\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error(\"Failed to create download stream\");\n }\n\n const chunks: BlobPart[] = [];\n let receivedLength = 0;\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) break;\n\n chunks.push(value);\n receivedLength += value.length;\n\n if (total > 0) {\n const progress = (receivedLength / total) * 100;\n setDownloadProgress(Math.round(progress));\n }\n }\n\n // Combine chunks into a single blob\n const blob = new Blob(chunks, {\n type: response.headers.get(\"content-type\") || \"video/mp4\",\n });\n\n // Create download link\n const url = URL.createObjectURL(blob);\n const link = document.createElement(\"a\");\n link.href = url;\n\n // Generate filename if not provided\n const defaultFilename = filename || `video-${Date.now()}.mp4`;\n link.download = defaultFilename;\n\n // Trigger download\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n\n // Clean up\n URL.revokeObjectURL(url);\n\n setDownloadProgress(100);\n setIsDownloading(false);\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Download failed\");\n setIsDownloading(false);\n setDownloadProgress(0);\n }\n },\n [videoRef]\n );\n\n // Alternative simple download method for direct video URLs\n const downloadDirect = useCallback(\n (filename?: string) => {\n if (!videoRef?.current) {\n setError(\"Video element not found\");\n return;\n }\n\n const video = videoRef.current;\n const videoSrc = video.src || video.currentSrc;\n\n if (!videoSrc) {\n setError(\"No video source found\");\n return;\n }\n\n try {\n setIsDownloading(true);\n setError(null);\n setDownloadProgress(0);\n\n const link = document.createElement(\"a\");\n link.href = videoSrc;\n link.download = filename || `video-${Date.now()}.mp4`;\n link.target = \"_blank\";\n\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n\n setIsDownloading(false);\n setDownloadProgress(100);\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Download failed\");\n setIsDownloading(false);\n setDownloadProgress(0);\n }\n },\n [videoRef]\n );\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n setIsDownloading(false);\n setDownloadProgress(0);\n setError(null);\n };\n }, []);\n\n return {\n downloadVideo,\n downloadDirect,\n isDownloading,\n downloadProgress,\n error,\n resetError: () => setError(null),\n };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useRange = (videoRef: VideoRef, range: [number, number]) => {\n React.useEffect(() => {\n if (!videoRef?.current || !range) return;\n\n const video = videoRef.current;\n\n if (video) {\n const handleTimeUpdate = () => {\n if (video.currentTime >= range[1]) {\n video.currentTime = range[0];\n } else if (video.currentTime <= range[0]) {\n video.currentTime = range[0];\n }\n };\n\n video.addEventListener(\"timeupdate\", handleTimeUpdate);\n\n return () => {\n video.removeEventListener(\"timeupdate\", handleTimeUpdate);\n };\n }\n }, [range, videoRef?.current]);\n};\n"],"mappings":"AAAA,OAAOA,MAAW,QAGX,IAAMC,EAAqB,CAChCC,EACAC,EAC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AK,EACtBE,EAAoB,CAAC,EACrBE,EAAS,IAAI,CACf,EACC,CAAC,CAAC,EAEE,CACL,cAAAC,EACA,eAAAmB,EACA,cAAAzB,EACA,iBAAAE,EACA,MAAAE,EACA,WAAY,IAAMC,EAAS,IAAI,CACjC,CACF,ECzJA,OAAOqB,MAAW,QAGX,IAAMC,GAAW,CAACC,EAAoBC,IAA4B,CACvEH,EAAM,UAAU,IAAM,CACpB,GAAI,EAACE,GAAA,MAAAA,EAAU,UAAW,CAACC,EAAO,OAElC,IAAMC,EAAQF,EAAS,QAEvB,GAAIE,EAAO,CACT,IAAMC,EAAmB,IAAM,EACzBD,EAAM,aAAeD,EAAM,CAAC,GAErBC,EAAM,aAAeD,EAAM,CAAC,KACrCC,EAAM,YAAcD,EAAM,CAAC,EAE/B,EAEA,OAAAC,EAAM,iBAAiB,aAAcC,CAAgB,EAE9C,IAAM,CACXD,EAAM,oBAAoB,aAAcC,CAAgB,CAC1D,CACF,CACF,EAAG,CAACF,EAAOD,GAAA,YAAAA,EAAU,OAAO,CAAC,CAC/B","names":["React","useAutoplayByForce","videoRef","enabled","setError","_a","error","retryError","React","useAutoplayOnVisible","videoRef","threshold","enabled","observer","entries","entry","_a","error","React","useFullscreen","videoRef","isFullscreen","setIsFullscreen","previousStylesRef","video","videoContainer","getFullscreenElement","checkFullscreenState","fullscreenElement","isCurrentlyFullscreen","toggleFullscreen","isSafari","React","useGetDuration","videoRef","isLoading","setIsLoading","duration","setDuration","getDuration","_a","_b","handleError","video","useEffect","useHotKeys","key","func","enabled","handleKeyDown","event","React","useMuteUnmute","videoRef","isMuted","setIsMuted","toggleMute","mute","unmute","handleVolumeChange","_a","usePictureInPicture","videoRef","video","error","videoContainer","React","usePlayPause","videoRef","isPlaying","setIsPlaying","togglePlay","play","pause","handlePlay","handlePause","_a","_b","React","useSeek","videoRef","value","seekForward","seekBackward","React","useSpeed","videoRef","speed","setSpeed","onChangeSpeed","React","useStartAt","videoRef","startAt","video","React","useCurrentTime","videoRef","interval","isPlaying","setIsPlaying","currentTime","setCurrentTime","intervalId","_a","video","handlePlay","handlePause","time","useEffect","useState","useVideoState","videoRef","isPlaying","setIsPlaying","isMuted","setIsMuted","isFullscreen","setIsFullscreen","video","handleVolumeChange","_a","handleFullscreenChange","React","useVolume","videoRef","initialVolume","volume","setVolume","onChangeVolume","React","useBuffer","videoRef","duration","isPlaying","setIsPlaying","buffered","setBuffered","intervalId","_a","_b","useEffect","useState","useCallback","useDownload","videoRef","isDownloading","setIsDownloading","downloadProgress","setDownloadProgress","error","setError","downloadVideo","filename","_a","video","videoSrc","response","contentLength","total","reader","chunks","receivedLength","done","value","progress","blob","url","link","defaultFilename","err","downloadDirect","React","useRange","videoRef","range","video","handleTimeUpdate"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import W from"react";var Q=(t,u,n)=>{W.useEffect(()=>{if(!(t!=null&&t.current)||!u)return;(async()=>{var s;try{await((s=t.current)==null?void 0:s.play())}catch(a){if(a instanceof Error&&a.name==="NotAllowedError"){if(n==null||n("NotAllowedError"),console.error("NotAllowedError"),t!=null&&t.current){t.current.muted=!0;try{await t.current.play()}catch(r){console.error(r)}}}else console.error(a)}})()},[u,t==null?void 0:t.current])};import A from"react";var Z=(t,u,n=!0)=>{A.useEffect(()=>{if(!(t!=null&&t.current)||!n)return;let c=new IntersectionObserver(s=>{s.forEach(a=>{var r;t!=null&&t.current&&(a.isIntersecting?t.current.play().catch(e=>{t.current&&(t.current.pause(),t.current.muted=!0,t.current.play(),console.error(e))}):(r=t.current)==null||r.pause())})},{threshold:u!=null?u:.5});return c.observe(t==null?void 0:t.current),()=>{c.disconnect()}},[t==null?void 0:t.current])};import L from"react";var v=t=>{let[u,n]=L.useState(!1),c=L.useRef(null);console.log("storing previous styles",c.current),L.useEffect(()=>{let a=t==null?void 0:t.current;if(!a)return;let r=a.closest("[data-zuude-video-wrapper]"),e=()=>document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null,l=()=>{let m=e(),o=!!m&&(m===r||m===a);n(o),a&&(console.log({isCurrentlyFullscreen:o}),o?(a.style.objectFit="contain",a.style.borderRadius="0",a.style.width="100%",a.style.height="100%",a.style.maxWidth="none",a.style.maxHeight="none",a.style.margin="0"):c.current&&(a.style.objectFit=c.current.objectFit,a.style.borderRadius=c.current.borderRadius,a.style.width=c.current.width,a.style.height=c.current.height,a.style.maxWidth=c.current.maxWidth,a.style.maxHeight=c.current.maxHeight,a.style.margin=c.current.margin,c.current=null))};return l(),document.addEventListener("fullscreenchange",l),document.addEventListener("webkitfullscreenchange",l),document.addEventListener("mozfullscreenchange",l),document.addEventListener("MSFullscreenChange",l),()=>{document.removeEventListener("fullscreenchange",l),document.removeEventListener("webkitfullscreenchange",l),document.removeEventListener("mozfullscreenchange",l),document.removeEventListener("MSFullscreenChange",l)}},[t]);let s=()=>{let a=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),r=t==null?void 0:t.current;if(r&&a){if(r.webkitEnterFullscreen){r.webkitEnterFullscreen();return}else if(r.requestFullscreen){r.requestFullscreen();return}}(r==null?void 0:r.closest("[data-zuude-video-wrapper]"))&&(u?document.exitFullscreen():(console.log({objectFit:r==null?void 0:r.style.objectFit}),console.log({objectFit:r==null?void 0:r.style}),c.current={objectFit:(r==null?void 0:r.style.objectFit)||"",borderRadius:(r==null?void 0:r.style.borderRadius)||"",width:(r==null?void 0:r.style.width)||"",height:(r==null?void 0:r.style.height)||"",maxWidth:(r==null?void 0:r.style.maxWidth)||"",maxHeight:(r==null?void 0:r.style.maxHeight)||"",margin:(r==null?void 0:r.style.margin)||""}))};return{isFullscreen:u!=null?u:!1,toggleFullscreen:s}};import i from"react";var rt=t=>{let[u,n]=i.useState(!1),[c,s]=i.useState(null);return i.useEffect(()=>{if(!(t!=null&&t.current))return;n(!0);let a=()=>{var l,m;s((m=(l=t.current)==null?void 0:l.duration)!=null?m:null),n(!1)},r=()=>{n(!1)},e=t.current;if(e.duration&&!isNaN(e.duration))s(e.duration),n(!1);else return e.addEventListener("loadedmetadata",a),e.addEventListener("error",r),e.addEventListener("loadeddata",a),()=>{e.removeEventListener("loadedmetadata",a),e.removeEventListener("error",r),e.removeEventListener("loadeddata",a)}},[t]),{duration:c,isLoading:u}};import{useEffect as K}from"react";var ut=(t,u,n=!0)=>{let c=s=>{s.key===t&&(s.preventDefault(),u(s))};K(()=>{if(n)return document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c)}},[t,u,n])};import h from"react";var at=t=>{let[u,n]=h.useState(!1),c=h.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!t.current.muted)},[t==null?void 0:t.current]),s=h.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!0)},[t==null?void 0:t.current]),a=h.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!1)},[t==null?void 0:t.current]);return h.useEffect(()=>{if(!(t!=null&&t.current))return;n(t.current.muted);let r=()=>{t.current&&n(t.current.muted)};return t.current.addEventListener("volumechange",r),()=>{var e;(e=t.current)==null||e.removeEventListener("volumechange",r)}},[t==null?void 0:t.current]),{toggleMute:c,isMuted:u,mute:s,unmute:a}};var mt=t=>({togglePictureInPicture:async()=>{let s=t==null?void 0:t.current;if(s)try{document.pictureInPictureElement?await document.exitPictureInPicture():await s.requestPictureInPicture()}catch(a){if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))s.webkitEnterFullscreen?s.webkitEnterFullscreen():s.requestFullscreen&&s.requestFullscreen();else{let e=s.closest("[data-zuude-video-wrapper]");e&&(document.fullscreenElement?await document.exitFullscreen():await e.requestFullscreen())}}},requestPictureInPicture:async()=>{let s=t==null?void 0:t.current;s&&await s.requestPictureInPicture()},exitPictureInPicture:async()=>{t!=null&&t.current&&await document.exitPictureInPicture()}});import b from"react";var yt=t=>{let[u,n]=b.useState(!1),c=b.useCallback(()=>{t!=null&&t.current&&(t.current.paused?t.current.play():t.current.pause())},[t==null?void 0:t.current]),s=b.useCallback(()=>{t!=null&&t.current&&t.current.play()},[t==null?void 0:t.current]),a=b.useCallback(()=>{t!=null&&t.current&&t.current.pause()},[t==null?void 0:t.current]);return b.useEffect(()=>{if(!(t!=null&&t.current))return;let r=()=>{n(!0)},e=()=>{n(!1)};if(n(!(t!=null&&t.current.paused)),t!=null&&t.current)return t.current.addEventListener("play",r),t.current.addEventListener("pause",e),()=>{var l,m;(l=t.current)==null||l.removeEventListener("play",r),(m=t.current)==null||m.removeEventListener("pause",e)}},[t==null?void 0:t.current]),{togglePlay:c,isPlaying:u,play:s,pause:a}};import q from"react";var ht=(t,u=10)=>{let n=q.useCallback(()=>{t!=null&&t.current&&(t.current.currentTime+=u)},[t==null?void 0:t.current]),c=q.useCallback(()=>{t!=null&&t.current&&(t.current.currentTime-=u)},[t==null?void 0:t.current]);return{seekForward:n,seekBackward:c}};import V from"react";var xt=t=>{let[u,n]=V.useState(1),c=s=>{n(s)};return V.useEffect(()=>{t!=null&&t.current&&n(t.current.playbackRate)},[t==null?void 0:t.current]),V.useEffect(()=>{t!=null&&t.current&&(t.current.playbackRate=u)},[u,t==null?void 0:t.current]),{speed:u,onChangeSpeed:c}};import $ from"react";var Vt=(t,u)=>{$.useEffect(()=>{if(!(t!=null&&t.current)||!u)return;let n=t==null?void 0:t.current;n&&u&&(n.currentTime=u)},[u,t==null?void 0:t.current])};import w from"react";var kt=(t,u=10)=>{let[n,c]=w.useState(!1),[s,a]=w.useState(0);return w.useEffect(()=>{if(t!=null&&t.current&&n){let e=setInterval(()=>{var l;a(((l=t.current)==null?void 0:l.currentTime)||0)},u);return()=>clearInterval(e)}},[t==null?void 0:t.current,n]),w.useEffect(()=>{if(!(t!=null&&t.current))return;let e=t.current,l=()=>c(!0),m=()=>c(!1);return e.addEventListener("play",l),e.addEventListener("pause",m),()=>{e.removeEventListener("play",l),e.removeEventListener("pause",m)}},[t==null?void 0:t.current]),{currentTime:s,onTimeUpdate:e=>{t!=null&&t.current&&(a(e),t.current.currentTime=e)}}};import{useEffect as P,useState as F}from"react";var Tt=t=>{let[u,n]=F(!1),[c,s]=F(!1),[a,r]=F(!1);return P(()=>{let e=t.current;if(e)return e.addEventListener("play",()=>n(!0)),e.addEventListener("pause",()=>n(!1)),()=>{e.removeEventListener("play",()=>n(!0)),e.removeEventListener("pause",()=>n(!1))}},[t]),P(()=>{if(!(t!=null&&t.current))return;s(t.current.muted);let e=()=>{t.current&&s(t.current.muted)};return t.current.addEventListener("volumechange",e),()=>{var l;(l=t.current)==null||l.removeEventListener("volumechange",e)}},[t]),P(()=>{if(!(t!=null&&t.current))return;let e=()=>{r(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[t]),{isPlaying:u,isMuted:c,isFullscreen:a}};import k from"react";var Mt=(t,u=100)=>{let[n,c]=k.useState(u),s=a=>{c(a)};return k.useEffect(()=>{t!=null&&t.current&&c(t.current.volume*100)},[t==null?void 0:t.current]),k.useEffect(()=>{t!=null&&t.current&&(t.current.volume=n/100)},[n,t==null?void 0:t.current]),{volume:n,onChangeVolume:s}};import x from"react";var Ut=(t,u)=>{let[n,c]=x.useState(!1),[s,a]=x.useState(0);return x.useEffect(()=>{if(t!=null&&t.current&&n){let r=setInterval(()=>{var e;(e=t.current)!=null&&e.buffered.length&&a(t.current.buffered.end(t.current.buffered.length-1))},10);return()=>clearInterval(r)}},[t==null?void 0:t.current,n]),x.useEffect(()=>{if(t!=null&&t.current)return t.current.addEventListener("play",()=>c(!0)),t.current.addEventListener("pause",()=>c(!1)),()=>{var r,e;(r=t.current)==null||r.removeEventListener("play",()=>c(!0)),(e=t.current)==null||e.removeEventListener("pause",()=>c(!1))}},[]),{buffered:s,bufferedPercentage:s/(u||0)*100||0}};import{useEffect as G,useState as I,useCallback as U}from"react";var Bt=t=>{let[u,n]=I(!1),[c,s]=I(0),[a,r]=I(null),e=U(async m=>{var p;if(!(t!=null&&t.current)){r("Video element not found");return}let o=t.current,g=o.src||o.currentSrc;if(!g){r("No video source found");return}try{n(!0),r(null),s(0);let y=await fetch(g);if(!y.ok)throw new Error(`Failed to fetch video: ${y.statusText}`);let S=y.headers.get("content-length"),C=S?parseInt(S,10):0,T=(p=y.body)==null?void 0:p.getReader();if(!T)throw new Error("Failed to create download stream");let j=[],D=0;for(;;){let{done:B,value:H}=await T.read();if(B)break;if(j.push(H),D+=H.length,C>0){let O=D/C*100;s(Math.round(O))}}let N=new Blob(j,{type:y.headers.get("content-type")||"video/mp4"}),M=URL.createObjectURL(N),E=document.createElement("a");E.href=M;let z=m||`video-${Date.now()}.mp4`;E.download=z,document.body.appendChild(E),E.click(),document.body.removeChild(E),URL.revokeObjectURL(M),s(100),n(!1)}catch(y){r(y instanceof Error?y.message:"Download failed"),n(!1),s(0)}},[t]),l=U(m=>{if(!(t!=null&&t.current)){r("Video element not found");return}let o=t.current,g=o.src||o.currentSrc;if(!g){r("No video source found");return}try{n(!0),r(null),s(0);let p=document.createElement("a");p.href=g,p.download=m||`video-${Date.now()}.mp4`,p.target="_blank",document.body.appendChild(p),p.click(),document.body.removeChild(p),n(!1),s(100)}catch(p){r(p instanceof Error?p.message:"Download failed"),n(!1),s(0)}},[t]);return G(()=>()=>{n(!1),s(0),r(null)},[]),{downloadVideo:e,downloadDirect:l,isDownloading:u,downloadProgress:c,error:a,resetError:()=>r(null)}};import _ from"react";var At=(t,u)=>{_.useEffect(()=>{if(!(t!=null&&t.current)||!u)return;let n=t.current;if(n){let c=()=>{(n.currentTime>=u[1]||n.currentTime<=u[0])&&(n.currentTime=u[0])};return n.addEventListener("timeupdate",c),()=>{n.removeEventListener("timeupdate",c)}}},[u,t==null?void 0:t.current])};export{Q as a,ut as b,ht as c,yt as d,at as e,v as f,mt as g,Z as h,rt as i,xt as j,Vt as k,kt as l,Tt as m,Mt as n,Ut as o,Bt as p,At as q};
|
|
2
|
+
//# sourceMappingURL=chunk-WY6YHDWT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-autoplay-by-force.tsx","../src/hooks/use-autoplay-on-visible.tsx","../src/hooks/use-fullscreen.tsx","../src/hooks/use-get-duration.tsx","../src/hooks/use-hot-keys.tsx","../src/hooks/use-mute-unmute.tsx","../src/hooks/use-picture-in-picture.tsx","../src/hooks/use-play-pause.tsx","../src/hooks/use-seek.tsx","../src/hooks/use-speed.tsx","../src/hooks/use-start-at.tsx","../src/hooks/use-current-time.tsx","../src/hooks/use-video-state.tsx","../src/hooks/use-volume.tsx","../src/hooks/use-buffer.tsx","../src/hooks/use-download.tsx","../src/hooks/use-range.tsx"],"sourcesContent":["import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useAutoplayByForce = (\n videoRef: VideoRef,\n enabled: boolean,\n setError?: (error: string | null) => void\n) => {\n React.useEffect(() => {\n if (!videoRef?.current || !enabled) return;\n\n const playVideo = async () => {\n try {\n await videoRef.current?.play();\n } catch (error) {\n // If autoplay fails, try muting and playing again\n if (error instanceof Error && error.name === \"NotAllowedError\") {\n setError?.(\"NotAllowedError\");\n console.error(\"NotAllowedError\");\n if (videoRef?.current) {\n videoRef.current.muted = true;\n try {\n await videoRef.current.play();\n } catch (retryError) {\n console.error(retryError);\n }\n }\n } else {\n console.error(error);\n }\n }\n };\n\n playVideo();\n }, [enabled, videoRef?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useAutoplayOnVisible = (\n videoRef: VideoRef,\n threshold: number | undefined,\n enabled = true\n) => {\n React.useEffect(() => {\n if (!videoRef?.current || !enabled) return;\n\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (!videoRef?.current) return;\n\n if (entry.isIntersecting) {\n videoRef.current.play().catch((error) => {\n if (!videoRef.current) return;\n\n videoRef.current.pause();\n videoRef.current.muted = true;\n videoRef.current.play();\n console.error(error);\n });\n } else {\n videoRef.current?.pause();\n }\n });\n },\n { threshold: threshold ?? 0.5 }\n );\n\n observer.observe(videoRef?.current);\n\n return () => {\n observer.disconnect();\n };\n }, [videoRef?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nconst useFullscreen = (videoRef: VideoRef) => {\n const [isFullscreen, setIsFullscreen] = React.useState(false);\n const previousStylesRef = React.useRef<{\n objectFit: string;\n borderRadius: string;\n width: string;\n height: string;\n maxWidth: string;\n maxHeight: string;\n margin: string;\n } | null>(null);\n console.log(\"storing previous styles\", previousStylesRef.current);\n\n React.useEffect(() => {\n const video = videoRef?.current;\n if (!video) return;\n\n const videoContainer = video.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement | null;\n\n // Helper to get fullscreen element with vendor prefix support\n const getFullscreenElement = (): Element | null => {\n return (\n document.fullscreenElement ||\n (document as any).webkitFullscreenElement ||\n (document as any).mozFullScreenElement ||\n (document as any).msFullscreenElement ||\n null\n );\n };\n\n const checkFullscreenState = () => {\n // Check if the container element is the fullscreen element\n const fullscreenElement = getFullscreenElement();\n const isCurrentlyFullscreen =\n !!fullscreenElement &&\n (fullscreenElement === videoContainer || fullscreenElement === video);\n\n setIsFullscreen(isCurrentlyFullscreen);\n\n // Apply styles based on fullscreen state\n if (video) {\n console.log({ isCurrentlyFullscreen });\n if (isCurrentlyFullscreen) {\n // Apply fullscreen styles\n video.style.objectFit = \"contain\";\n video.style.borderRadius = \"0\";\n video.style.width = \"100%\";\n video.style.height = \"100%\";\n video.style.maxWidth = \"none\";\n video.style.maxHeight = \"none\";\n video.style.margin = \"0\";\n } else {\n // Restore previous styles when exiting fullscreen\n if (previousStylesRef.current) {\n video.style.objectFit = previousStylesRef.current.objectFit;\n video.style.borderRadius = previousStylesRef.current.borderRadius;\n video.style.width = previousStylesRef.current.width;\n video.style.height = previousStylesRef.current.height;\n video.style.maxWidth = previousStylesRef.current.maxWidth;\n video.style.maxHeight = previousStylesRef.current.maxHeight;\n video.style.margin = previousStylesRef.current.margin;\n previousStylesRef.current = null;\n }\n }\n }\n };\n\n // Check initial state\n checkFullscreenState();\n\n // Listen for fullscreen changes\n document.addEventListener(\"fullscreenchange\", checkFullscreenState);\n\n // Also listen for vendor-prefixed events for better browser support\n document.addEventListener(\"webkitfullscreenchange\", checkFullscreenState);\n document.addEventListener(\"mozfullscreenchange\", checkFullscreenState);\n document.addEventListener(\"MSFullscreenChange\", checkFullscreenState);\n\n return () => {\n document.removeEventListener(\"fullscreenchange\", checkFullscreenState);\n document.removeEventListener(\n \"webkitfullscreenchange\",\n checkFullscreenState\n );\n document.removeEventListener(\"mozfullscreenchange\", checkFullscreenState);\n document.removeEventListener(\"MSFullscreenChange\", checkFullscreenState);\n };\n }, [videoRef]);\n\n const toggleFullscreen = () => {\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n const video = videoRef?.current;\n\n if (video && isSafari) {\n if ((video as any).webkitEnterFullscreen) {\n (video as any).webkitEnterFullscreen();\n return;\n } else if (video.requestFullscreen) {\n video.requestFullscreen();\n return;\n }\n }\n\n const videoContainer = video?.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement;\n\n if (videoContainer) {\n if (!isFullscreen) {\n console.log({ objectFit: video?.style.objectFit });\n console.log({ objectFit: video?.style });\n previousStylesRef.current = {\n objectFit: video?.style.objectFit || \"\",\n borderRadius: video?.style.borderRadius || \"\",\n width: video?.style.width || \"\",\n height: video?.style.height || \"\",\n maxWidth: video?.style.maxWidth || \"\",\n maxHeight: video?.style.maxHeight || \"\",\n margin: video?.style.margin || \"\",\n };\n // videoContainer.requestFullscreen();\n } else {\n document.exitFullscreen();\n }\n }\n };\n\n return { isFullscreen: isFullscreen ?? false, toggleFullscreen };\n};\n\nexport { useFullscreen };\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useGetDuration = (videoRef: VideoRef) => {\n const [isLoading, setIsLoading] = React.useState(false);\n const [duration, setDuration] = React.useState<number | null>(null);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n setIsLoading(true);\n\n const getDuration = () => {\n setDuration(videoRef.current?.duration ?? null);\n setIsLoading(false);\n };\n\n const handleError = () => {\n setIsLoading(false);\n };\n\n const video = videoRef.current;\n\n // Check if duration is already available\n if (video.duration && !isNaN(video.duration)) {\n setDuration(video.duration);\n setIsLoading(false);\n } else {\n // Add event listeners\n video.addEventListener(\"loadedmetadata\", getDuration);\n video.addEventListener(\"error\", handleError);\n video.addEventListener(\"loadeddata\", getDuration);\n\n return () => {\n video.removeEventListener(\"loadedmetadata\", getDuration);\n video.removeEventListener(\"error\", handleError);\n video.removeEventListener(\"loadeddata\", getDuration);\n };\n }\n }, [videoRef]);\n\n return { duration, isLoading };\n};\n","import { useEffect } from \"react\";\n\nexport const useHotKeys = (\n key: string,\n func: (event: KeyboardEvent) => void,\n enabled = true\n) => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === key) {\n event.preventDefault();\n func(event);\n }\n };\n\n useEffect(() => {\n if (!enabled) return;\n\n document.addEventListener(\"keydown\", handleKeyDown);\n\n return () => {\n document.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [key, func, enabled]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useMuteUnmute = (videoRef: VideoRef) => {\n const [isMuted, setIsMuted] = React.useState(false);\n\n const toggleMute = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = !videoRef.current.muted;\n }\n }, [videoRef?.current]);\n\n const mute = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = true;\n }\n }, [videoRef?.current]);\n\n const unmute = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = false;\n }\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n // Set the initial state\n setIsMuted(videoRef.current.muted);\n\n const handleVolumeChange = () => {\n if (videoRef.current) {\n setIsMuted(videoRef.current.muted);\n }\n };\n\n videoRef.current.addEventListener(\"volumechange\", handleVolumeChange);\n\n return () => {\n videoRef.current?.removeEventListener(\"volumechange\", handleVolumeChange);\n };\n }, [videoRef?.current]);\n\n return { toggleMute, isMuted, mute, unmute };\n};\n","import type { VideoRef } from \"../types\";\n\nexport const usePictureInPicture = (videoRef: VideoRef) => {\n const togglePictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n\n try {\n if (document.pictureInPictureElement) {\n await document.exitPictureInPicture();\n } else {\n await video.requestPictureInPicture();\n }\n } catch (error) {\n // Fallback for browsers that don't support PiP\n const isSafari = /^((?!chrome|android).)*safari/i.test(\n navigator.userAgent\n );\n\n if (isSafari) {\n if ((video as any).webkitEnterFullscreen) {\n (video as any).webkitEnterFullscreen();\n } else if (video.requestFullscreen) {\n video.requestFullscreen();\n }\n } else {\n const videoContainer = video.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement;\n if (videoContainer) {\n if (!document.fullscreenElement) {\n await videoContainer.requestFullscreen();\n } else {\n await document.exitFullscreen();\n }\n }\n }\n }\n };\n\n const requestPictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n await video.requestPictureInPicture();\n };\n\n const exitPictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n await document.exitPictureInPicture();\n };\n\n return {\n togglePictureInPicture,\n requestPictureInPicture,\n exitPictureInPicture,\n };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const usePlayPause = (videoRef: VideoRef) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n\n const togglePlay = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.paused\n ? videoRef.current.play()\n : videoRef.current.pause();\n }\n }, [videoRef?.current]);\n\n const play = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.play();\n }\n }, [videoRef?.current]);\n\n const pause = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.pause();\n }\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n const handlePlay = () => {\n setIsPlaying(true);\n };\n const handlePause = () => {\n setIsPlaying(false);\n };\n\n setIsPlaying(!videoRef?.current.paused);\n\n if (videoRef?.current) {\n videoRef.current.addEventListener(\"play\", handlePlay);\n videoRef.current.addEventListener(\"pause\", handlePause);\n\n return () => {\n videoRef.current?.removeEventListener(\"play\", handlePlay);\n videoRef.current?.removeEventListener(\"pause\", handlePause);\n };\n }\n }, [videoRef?.current]);\n\n return { togglePlay, isPlaying, play, pause };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useSeek = (videoRef: VideoRef, value = 10) => {\n const seekForward = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.currentTime += value;\n }\n }, [videoRef?.current]);\n\n const seekBackward = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.currentTime -= value;\n }\n }, [videoRef?.current]);\n\n return { seekForward, seekBackward };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useSpeed = (videoRef: VideoRef) => {\n const [speed, setSpeed] = React.useState(1);\n\n const onChangeSpeed = (speed: number) => {\n setSpeed(speed);\n };\n\n // Get the speed from the video element\n React.useEffect(() => {\n if (!videoRef?.current) return;\n setSpeed(videoRef.current.playbackRate);\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.playbackRate = speed;\n }, [speed, videoRef?.current]);\n\n return { speed, onChangeSpeed };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useStartAt = (videoRef: VideoRef, startAt: number) => {\n React.useEffect(() => {\n if (!videoRef?.current || !startAt) return;\n\n const video = videoRef?.current;\n if (video && startAt) {\n video.currentTime = startAt;\n }\n }, [startAt, videoRef?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types.js\";\n\nexport const useCurrentTime = (videoRef: VideoRef, interval = 10) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n const [currentTime, setCurrentTime] = React.useState(0);\n\n React.useEffect(() => {\n if (videoRef?.current && isPlaying) {\n const intervalId = setInterval(() => {\n setCurrentTime(videoRef.current?.currentTime || 0);\n }, interval);\n\n return () => clearInterval(intervalId);\n }\n }, [videoRef?.current, isPlaying]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n const video = videoRef.current;\n\n // Store handlers in variables for proper cleanup (critical for Safari memory safety)\n const handlePlay = () => setIsPlaying(true);\n const handlePause = () => setIsPlaying(false);\n\n video.addEventListener(\"play\", handlePlay);\n video.addEventListener(\"pause\", handlePause);\n\n return () => {\n video.removeEventListener(\"play\", handlePlay);\n video.removeEventListener(\"pause\", handlePause);\n };\n }, [videoRef?.current]);\n\n const onTimeUpdate = (time: number) => {\n if (videoRef?.current) {\n setCurrentTime(time);\n videoRef.current.currentTime = time;\n }\n };\n\n return {\n currentTime,\n onTimeUpdate,\n };\n};\n","import { RefObject, useEffect, useState } from \"react\";\n\nconst useVideoState = (videoRef: RefObject<HTMLVideoElement | null>) => {\n const [isPlaying, setIsPlaying] = useState(false);\n const [isMuted, setIsMuted] = useState(false);\n const [isFullscreen, setIsFullscreen] = useState(false);\n\n useEffect(() => {\n const video = videoRef.current;\n\n if (video) {\n video.addEventListener(\"play\", () => setIsPlaying(true));\n video.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n video.removeEventListener(\"play\", () => setIsPlaying(true));\n video.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }\n }, [videoRef]);\n\n useEffect(() => {\n if (!videoRef?.current) return;\n\n // Set the initial state\n setIsMuted(videoRef.current.muted);\n\n const handleVolumeChange = () => {\n if (videoRef.current) {\n setIsMuted(videoRef.current.muted);\n }\n };\n\n videoRef.current.addEventListener(\"volumechange\", handleVolumeChange);\n\n return () => {\n videoRef.current?.removeEventListener(\"volumechange\", handleVolumeChange);\n };\n }, [videoRef]);\n\n useEffect(() => {\n if (!videoRef?.current) return;\n\n const handleFullscreenChange = () => {\n setIsFullscreen(!!document.fullscreenElement);\n };\n\n document.addEventListener(\"fullscreenchange\", handleFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", handleFullscreenChange);\n }, [videoRef]);\n\n return { isPlaying, isMuted, isFullscreen };\n};\n\nexport { useVideoState };\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useVolume = (videoRef: VideoRef, initialVolume = 100) => {\n const [volume, setVolume] = React.useState(initialVolume);\n\n const onChangeVolume = (volume: number) => {\n setVolume(volume);\n };\n\n // Get the volume from the video element\n React.useEffect(() => {\n if (!videoRef?.current) return;\n setVolume(videoRef.current.volume * 100);\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.volume = volume / 100;\n }, [volume, videoRef?.current]);\n\n return { volume, onChangeVolume };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types.js\";\n\nexport const useBuffer = (videoRef: VideoRef, duration?: number) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n const [buffered, setBuffered] = React.useState(0);\n\n React.useEffect(() => {\n if (videoRef?.current && isPlaying) {\n const intervalId = setInterval(() => {\n if (videoRef.current?.buffered.length) {\n setBuffered(\n videoRef.current.buffered.end(videoRef.current.buffered.length - 1)\n );\n }\n }, 10);\n\n return () => clearInterval(intervalId);\n }\n }, [videoRef?.current, isPlaying]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.addEventListener(\"play\", () => setIsPlaying(true));\n videoRef.current.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n videoRef.current?.removeEventListener(\"play\", () => setIsPlaying(true));\n videoRef.current?.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }, []);\n\n return {\n buffered,\n bufferedPercentage: (buffered / (duration || 0)) * 100 || 0,\n };\n};\n","import { useEffect, useState, useCallback } from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useDownload = (videoRef: VideoRef) => {\n const [isDownloading, setIsDownloading] = useState(false);\n const [downloadProgress, setDownloadProgress] = useState(0);\n const [error, setError] = useState<string | null>(null);\n\n const downloadVideo = useCallback(\n async (filename?: string) => {\n if (!videoRef?.current) {\n setError(\"Video element not found\");\n return;\n }\n\n const video = videoRef.current;\n const videoSrc = video.src || video.currentSrc;\n\n if (!videoSrc) {\n setError(\"No video source found\");\n return;\n }\n\n try {\n setIsDownloading(true);\n setError(null);\n setDownloadProgress(0);\n\n // Fetch the video file\n const response = await fetch(videoSrc);\n\n if (!response.ok) {\n throw new Error(`Failed to fetch video: ${response.statusText}`);\n }\n\n // Get the content length for progress tracking\n const contentLength = response.headers.get(\"content-length\");\n const total = contentLength ? parseInt(contentLength, 10) : 0;\n\n // Create a readable stream to track progress\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error(\"Failed to create download stream\");\n }\n\n const chunks: BlobPart[] = [];\n let receivedLength = 0;\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) break;\n\n chunks.push(value);\n receivedLength += value.length;\n\n if (total > 0) {\n const progress = (receivedLength / total) * 100;\n setDownloadProgress(Math.round(progress));\n }\n }\n\n // Combine chunks into a single blob\n const blob = new Blob(chunks, {\n type: response.headers.get(\"content-type\") || \"video/mp4\",\n });\n\n // Create download link\n const url = URL.createObjectURL(blob);\n const link = document.createElement(\"a\");\n link.href = url;\n\n // Generate filename if not provided\n const defaultFilename = filename || `video-${Date.now()}.mp4`;\n link.download = defaultFilename;\n\n // Trigger download\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n\n // Clean up\n URL.revokeObjectURL(url);\n\n setDownloadProgress(100);\n setIsDownloading(false);\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Download failed\");\n setIsDownloading(false);\n setDownloadProgress(0);\n }\n },\n [videoRef]\n );\n\n // Alternative simple download method for direct video URLs\n const downloadDirect = useCallback(\n (filename?: string) => {\n if (!videoRef?.current) {\n setError(\"Video element not found\");\n return;\n }\n\n const video = videoRef.current;\n const videoSrc = video.src || video.currentSrc;\n\n if (!videoSrc) {\n setError(\"No video source found\");\n return;\n }\n\n try {\n setIsDownloading(true);\n setError(null);\n setDownloadProgress(0);\n\n const link = document.createElement(\"a\");\n link.href = videoSrc;\n link.download = filename || `video-${Date.now()}.mp4`;\n link.target = \"_blank\";\n\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n\n setIsDownloading(false);\n setDownloadProgress(100);\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Download failed\");\n setIsDownloading(false);\n setDownloadProgress(0);\n }\n },\n [videoRef]\n );\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n setIsDownloading(false);\n setDownloadProgress(0);\n setError(null);\n };\n }, []);\n\n return {\n downloadVideo,\n downloadDirect,\n isDownloading,\n downloadProgress,\n error,\n resetError: () => setError(null),\n };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useRange = (videoRef: VideoRef, range: [number, number]) => {\n React.useEffect(() => {\n if (!videoRef?.current || !range) return;\n\n const video = videoRef.current;\n\n if (video) {\n const handleTimeUpdate = () => {\n if (video.currentTime >= range[1]) {\n video.currentTime = range[0];\n } else if (video.currentTime <= range[0]) {\n video.currentTime = range[0];\n }\n };\n\n video.addEventListener(\"timeupdate\", handleTimeUpdate);\n\n return () => {\n video.removeEventListener(\"timeupdate\", handleTimeUpdate);\n };\n }\n }, [range, videoRef?.current]);\n};\n"],"mappings":"AAAA,OAAOA,MAAW,QAGX,IAAMC,EAAqB,CAChCC,EACAC,EACAC,IACG,CACHJ,EAAM,UAAU,IAAM,CACpB,GAAI,EAACE,GAAA,MAAAA,EAAU,UAAW,CAACC,EAAS,QAElB,SAAY,CAXlC,IAAAE,EAYM,GAAI,CACF,OAAMA,EAAAH,EAAS,UAAT,YAAAG,EAAkB,OAC1B,OAASC,EAAO,CAEd,GAAIA,aAAiB,OAASA,EAAM,OAAS,mBAG3C,GAFAF,GAAA,MAAAA,EAAW,mBACX,QAAQ,MAAM,iBAAiB,EAC3BF,GAAA,MAAAA,EAAU,QAAS,CACrBA,EAAS,QAAQ,MAAQ,GACzB,GAAI,CACF,MAAMA,EAAS,QAAQ,KAAK,CAC9B,OAASK,EAAY,CACnB,QAAQ,MAAMA,CAAU,CAC1B,CACF,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AAAA,EAAU,UAAW,CAACC,EAAO,OAElC,IAAMC,EAAQF,EAAS,QAEvB,GAAIE,EAAO,CACT,IAAMC,EAAmB,IAAM,EACzBD,EAAM,aAAeD,EAAM,CAAC,GAErBC,EAAM,aAAeD,EAAM,CAAC,KACrCC,EAAM,YAAcD,EAAM,CAAC,EAE/B,EAEA,OAAAC,EAAM,iBAAiB,aAAcC,CAAgB,EAE9C,IAAM,CACXD,EAAM,oBAAoB,aAAcC,CAAgB,CAC1D,CACF,CACF,EAAG,CAACF,EAAOD,GAAA,YAAAA,EAAU,OAAO,CAAC,CAC/B","names":["React","useAutoplayByForce","videoRef","enabled","setError","_a","error","retryError","React","useAutoplayOnVisible","videoRef","threshold","enabled","observer","entries","entry","_a","error","React","useFullscreen","videoRef","isFullscreen","setIsFullscreen","previousStylesRef","video","videoContainer","getFullscreenElement","checkFullscreenState","fullscreenElement","isCurrentlyFullscreen","toggleFullscreen","isSafari","React","useGetDuration","videoRef","isLoading","setIsLoading","duration","setDuration","getDuration","_a","_b","handleError","video","useEffect","useHotKeys","key","func","enabled","handleKeyDown","event","React","useMuteUnmute","videoRef","isMuted","setIsMuted","toggleMute","mute","unmute","handleVolumeChange","_a","usePictureInPicture","videoRef","video","error","videoContainer","React","usePlayPause","videoRef","isPlaying","setIsPlaying","togglePlay","play","pause","handlePlay","handlePause","_a","_b","React","useSeek","videoRef","value","seekForward","seekBackward","React","useSpeed","videoRef","speed","setSpeed","onChangeSpeed","React","useStartAt","videoRef","startAt","video","React","useCurrentTime","videoRef","interval","isPlaying","setIsPlaying","currentTime","setCurrentTime","intervalId","_a","video","handlePlay","handlePause","time","useEffect","useState","useVideoState","videoRef","isPlaying","setIsPlaying","isMuted","setIsMuted","isFullscreen","setIsFullscreen","video","handleVolumeChange","_a","handleFullscreenChange","React","useVolume","videoRef","initialVolume","volume","setVolume","onChangeVolume","React","useBuffer","videoRef","duration","isPlaying","setIsPlaying","buffered","setBuffered","intervalId","_a","_b","useEffect","useState","useCallback","useDownload","videoRef","isDownloading","setIsDownloading","downloadProgress","setDownloadProgress","error","setError","downloadVideo","filename","_a","video","videoSrc","response","contentLength","total","reader","chunks","receivedLength","done","value","progress","blob","url","link","defaultFilename","err","downloadDirect","React","useRange","videoRef","range","video","handleTimeUpdate"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import W from"react";var Q=(t,u,n)=>{W.useEffect(()=>{if(!(t!=null&&t.current)||!u)return;(async()=>{var s;try{await((s=t.current)==null?void 0:s.play())}catch(a){if(a instanceof Error&&a.name==="NotAllowedError"){if(n==null||n("NotAllowedError"),console.error("NotAllowedError"),t!=null&&t.current){t.current.muted=!0;try{await t.current.play()}catch(r){console.error(r)}}}else console.error(a)}})()},[u,t==null?void 0:t.current])};import A from"react";var Z=(t,u,n=!0)=>{A.useEffect(()=>{if(!(t!=null&&t.current)||!n)return;let c=new IntersectionObserver(s=>{s.forEach(a=>{var r;t!=null&&t.current&&(a.isIntersecting?t.current.play().catch(e=>{t.current&&(t.current.pause(),t.current.muted=!0,t.current.play(),console.error(e))}):(r=t.current)==null||r.pause())})},{threshold:u!=null?u:.5});return c.observe(t==null?void 0:t.current),()=>{c.disconnect()}},[t==null?void 0:t.current])};import L from"react";var v=t=>{let[u,n]=L.useState(!1),c=L.useRef(null);console.log("storing previous styles",c.current),L.useEffect(()=>{let a=t==null?void 0:t.current;if(!a)return;let r=a.closest("[data-zuude-video-wrapper]"),e=()=>document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null,l=()=>{let m=e(),o=!!m&&(m===r||m===a);n(o),a&&(console.log({isCurrentlyFullscreen:o}),o?(a.style.objectFit="contain",a.style.borderRadius="0",a.style.width="100%",a.style.height="100%",a.style.maxWidth="none",a.style.maxHeight="none",a.style.margin="0"):c.current&&(a.style.objectFit=c.current.objectFit,a.style.borderRadius=c.current.borderRadius,a.style.width=c.current.width,a.style.height=c.current.height,a.style.maxWidth=c.current.maxWidth,a.style.maxHeight=c.current.maxHeight,a.style.margin=c.current.margin,c.current=null))};return l(),document.addEventListener("fullscreenchange",l),document.addEventListener("webkitfullscreenchange",l),document.addEventListener("mozfullscreenchange",l),document.addEventListener("MSFullscreenChange",l),()=>{document.removeEventListener("fullscreenchange",l),document.removeEventListener("webkitfullscreenchange",l),document.removeEventListener("mozfullscreenchange",l),document.removeEventListener("MSFullscreenChange",l)}},[t]);let s=()=>{let a=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),r=t==null?void 0:t.current;if(r&&a){if(r.webkitEnterFullscreen){r.webkitEnterFullscreen();return}else if(r.requestFullscreen){r.requestFullscreen();return}}let e=r==null?void 0:r.closest("[data-zuude-video-wrapper]");e&&(u?document.exitFullscreen():(console.log({objectFit:r==null?void 0:r.style.objectFit}),c.current={objectFit:(r==null?void 0:r.style.objectFit)||"",borderRadius:(r==null?void 0:r.style.borderRadius)||"",width:(r==null?void 0:r.style.width)||"",height:(r==null?void 0:r.style.height)||"",maxWidth:(r==null?void 0:r.style.maxWidth)||"",maxHeight:(r==null?void 0:r.style.maxHeight)||"",margin:(r==null?void 0:r.style.margin)||""},e.requestFullscreen()))};return{isFullscreen:u!=null?u:!1,toggleFullscreen:s}};import V from"react";var rt=t=>{let[u,n]=V.useState(!1),[c,s]=V.useState(null);return V.useEffect(()=>{if(!(t!=null&&t.current))return;n(!0);let a=()=>{var l,m;s((m=(l=t.current)==null?void 0:l.duration)!=null?m:null),n(!1)},r=()=>{n(!1)},e=t.current;if(e.duration&&!isNaN(e.duration))s(e.duration),n(!1);else return e.addEventListener("loadedmetadata",a),e.addEventListener("error",r),e.addEventListener("loadeddata",a),()=>{e.removeEventListener("loadedmetadata",a),e.removeEventListener("error",r),e.removeEventListener("loadeddata",a)}},[t]),{duration:c,isLoading:u}};import{useEffect as K}from"react";var ut=(t,u,n=!0)=>{let c=s=>{s.key===t&&(s.preventDefault(),u(s))};K(()=>{if(n)return document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c)}},[t,u,n])};import h from"react";var at=t=>{let[u,n]=h.useState(!1),c=h.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!t.current.muted)},[t==null?void 0:t.current]),s=h.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!0)},[t==null?void 0:t.current]),a=h.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!1)},[t==null?void 0:t.current]);return h.useEffect(()=>{if(!(t!=null&&t.current))return;n(t.current.muted);let r=()=>{t.current&&n(t.current.muted)};return t.current.addEventListener("volumechange",r),()=>{var e;(e=t.current)==null||e.removeEventListener("volumechange",r)}},[t==null?void 0:t.current]),{toggleMute:c,isMuted:u,mute:s,unmute:a}};var mt=t=>({togglePictureInPicture:async()=>{let s=t==null?void 0:t.current;if(s)try{document.pictureInPictureElement?await document.exitPictureInPicture():await s.requestPictureInPicture()}catch(a){if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))s.webkitEnterFullscreen?s.webkitEnterFullscreen():s.requestFullscreen&&s.requestFullscreen();else{let e=s.closest("[data-zuude-video-wrapper]");e&&(document.fullscreenElement?await document.exitFullscreen():await e.requestFullscreen())}}},requestPictureInPicture:async()=>{let s=t==null?void 0:t.current;s&&await s.requestPictureInPicture()},exitPictureInPicture:async()=>{t!=null&&t.current&&await document.exitPictureInPicture()}});import b from"react";var yt=t=>{let[u,n]=b.useState(!1),c=b.useCallback(()=>{t!=null&&t.current&&(t.current.paused?t.current.play():t.current.pause())},[t==null?void 0:t.current]),s=b.useCallback(()=>{t!=null&&t.current&&t.current.play()},[t==null?void 0:t.current]),a=b.useCallback(()=>{t!=null&&t.current&&t.current.pause()},[t==null?void 0:t.current]);return b.useEffect(()=>{if(!(t!=null&&t.current))return;let r=()=>{n(!0)},e=()=>{n(!1)};if(n(!(t!=null&&t.current.paused)),t!=null&&t.current)return t.current.addEventListener("play",r),t.current.addEventListener("pause",e),()=>{var l,m;(l=t.current)==null||l.removeEventListener("play",r),(m=t.current)==null||m.removeEventListener("pause",e)}},[t==null?void 0:t.current]),{togglePlay:c,isPlaying:u,play:s,pause:a}};import q from"react";var ht=(t,u=10)=>{let n=q.useCallback(()=>{t!=null&&t.current&&(t.current.currentTime+=u)},[t==null?void 0:t.current]),c=q.useCallback(()=>{t!=null&&t.current&&(t.current.currentTime-=u)},[t==null?void 0:t.current]);return{seekForward:n,seekBackward:c}};import i from"react";var xt=t=>{let[u,n]=i.useState(1),c=s=>{n(s)};return i.useEffect(()=>{t!=null&&t.current&&n(t.current.playbackRate)},[t==null?void 0:t.current]),i.useEffect(()=>{t!=null&&t.current&&(t.current.playbackRate=u)},[u,t==null?void 0:t.current]),{speed:u,onChangeSpeed:c}};import $ from"react";var it=(t,u)=>{$.useEffect(()=>{if(!(t!=null&&t.current)||!u)return;let n=t==null?void 0:t.current;n&&u&&(n.currentTime=u)},[u,t==null?void 0:t.current])};import w from"react";var kt=(t,u=10)=>{let[n,c]=w.useState(!1),[s,a]=w.useState(0);return w.useEffect(()=>{if(t!=null&&t.current&&n){let e=setInterval(()=>{var l;a(((l=t.current)==null?void 0:l.currentTime)||0)},u);return()=>clearInterval(e)}},[t==null?void 0:t.current,n]),w.useEffect(()=>{if(!(t!=null&&t.current))return;let e=t.current,l=()=>c(!0),m=()=>c(!1);return e.addEventListener("play",l),e.addEventListener("pause",m),()=>{e.removeEventListener("play",l),e.removeEventListener("pause",m)}},[t==null?void 0:t.current]),{currentTime:s,onTimeUpdate:e=>{t!=null&&t.current&&(a(e),t.current.currentTime=e)}}};import{useEffect as P,useState as F}from"react";var Tt=t=>{let[u,n]=F(!1),[c,s]=F(!1),[a,r]=F(!1);return P(()=>{let e=t.current;if(e)return e.addEventListener("play",()=>n(!0)),e.addEventListener("pause",()=>n(!1)),()=>{e.removeEventListener("play",()=>n(!0)),e.removeEventListener("pause",()=>n(!1))}},[t]),P(()=>{if(!(t!=null&&t.current))return;s(t.current.muted);let e=()=>{t.current&&s(t.current.muted)};return t.current.addEventListener("volumechange",e),()=>{var l;(l=t.current)==null||l.removeEventListener("volumechange",e)}},[t]),P(()=>{if(!(t!=null&&t.current))return;let e=()=>{r(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[t]),{isPlaying:u,isMuted:c,isFullscreen:a}};import k from"react";var Mt=(t,u=100)=>{let[n,c]=k.useState(u),s=a=>{c(a)};return k.useEffect(()=>{t!=null&&t.current&&c(t.current.volume*100)},[t==null?void 0:t.current]),k.useEffect(()=>{t!=null&&t.current&&(t.current.volume=n/100)},[n,t==null?void 0:t.current]),{volume:n,onChangeVolume:s}};import x from"react";var Ut=(t,u)=>{let[n,c]=x.useState(!1),[s,a]=x.useState(0);return x.useEffect(()=>{if(t!=null&&t.current&&n){let r=setInterval(()=>{var e;(e=t.current)!=null&&e.buffered.length&&a(t.current.buffered.end(t.current.buffered.length-1))},10);return()=>clearInterval(r)}},[t==null?void 0:t.current,n]),x.useEffect(()=>{if(t!=null&&t.current)return t.current.addEventListener("play",()=>c(!0)),t.current.addEventListener("pause",()=>c(!1)),()=>{var r,e;(r=t.current)==null||r.removeEventListener("play",()=>c(!0)),(e=t.current)==null||e.removeEventListener("pause",()=>c(!1))}},[]),{buffered:s,bufferedPercentage:s/(u||0)*100||0}};import{useEffect as G,useState as I,useCallback as U}from"react";var Bt=t=>{let[u,n]=I(!1),[c,s]=I(0),[a,r]=I(null),e=U(async m=>{var p;if(!(t!=null&&t.current)){r("Video element not found");return}let o=t.current,g=o.src||o.currentSrc;if(!g){r("No video source found");return}try{n(!0),r(null),s(0);let y=await fetch(g);if(!y.ok)throw new Error(`Failed to fetch video: ${y.statusText}`);let S=y.headers.get("content-length"),C=S?parseInt(S,10):0,T=(p=y.body)==null?void 0:p.getReader();if(!T)throw new Error("Failed to create download stream");let j=[],D=0;for(;;){let{done:B,value:H}=await T.read();if(B)break;if(j.push(H),D+=H.length,C>0){let O=D/C*100;s(Math.round(O))}}let N=new Blob(j,{type:y.headers.get("content-type")||"video/mp4"}),M=URL.createObjectURL(N),E=document.createElement("a");E.href=M;let z=m||`video-${Date.now()}.mp4`;E.download=z,document.body.appendChild(E),E.click(),document.body.removeChild(E),URL.revokeObjectURL(M),s(100),n(!1)}catch(y){r(y instanceof Error?y.message:"Download failed"),n(!1),s(0)}},[t]),l=U(m=>{if(!(t!=null&&t.current)){r("Video element not found");return}let o=t.current,g=o.src||o.currentSrc;if(!g){r("No video source found");return}try{n(!0),r(null),s(0);let p=document.createElement("a");p.href=g,p.download=m||`video-${Date.now()}.mp4`,p.target="_blank",document.body.appendChild(p),p.click(),document.body.removeChild(p),n(!1),s(100)}catch(p){r(p instanceof Error?p.message:"Download failed"),n(!1),s(0)}},[t]);return G(()=>()=>{n(!1),s(0),r(null)},[]),{downloadVideo:e,downloadDirect:l,isDownloading:u,downloadProgress:c,error:a,resetError:()=>r(null)}};import _ from"react";var At=(t,u)=>{_.useEffect(()=>{if(!(t!=null&&t.current)||!u)return;let n=t.current;if(n){let c=()=>{(n.currentTime>=u[1]||n.currentTime<=u[0])&&(n.currentTime=u[0])};return n.addEventListener("timeupdate",c),()=>{n.removeEventListener("timeupdate",c)}}},[u,t==null?void 0:t.current])};export{Q as a,ut as b,ht as c,yt as d,at as e,v as f,mt as g,Z as h,rt as i,xt as j,it as k,kt as l,Tt as m,Mt as n,Ut as o,Bt as p,At as q};
|
|
2
|
+
//# sourceMappingURL=chunk-YID6OIKP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-autoplay-by-force.tsx","../src/hooks/use-autoplay-on-visible.tsx","../src/hooks/use-fullscreen.tsx","../src/hooks/use-get-duration.tsx","../src/hooks/use-hot-keys.tsx","../src/hooks/use-mute-unmute.tsx","../src/hooks/use-picture-in-picture.tsx","../src/hooks/use-play-pause.tsx","../src/hooks/use-seek.tsx","../src/hooks/use-speed.tsx","../src/hooks/use-start-at.tsx","../src/hooks/use-current-time.tsx","../src/hooks/use-video-state.tsx","../src/hooks/use-volume.tsx","../src/hooks/use-buffer.tsx","../src/hooks/use-download.tsx","../src/hooks/use-range.tsx"],"sourcesContent":["import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useAutoplayByForce = (\n videoRef: VideoRef,\n enabled: boolean,\n setError?: (error: string | null) => void\n) => {\n React.useEffect(() => {\n if (!videoRef?.current || !enabled) return;\n\n const playVideo = async () => {\n try {\n await videoRef.current?.play();\n } catch (error) {\n // If autoplay fails, try muting and playing again\n if (error instanceof Error && error.name === \"NotAllowedError\") {\n setError?.(\"NotAllowedError\");\n console.error(\"NotAllowedError\");\n if (videoRef?.current) {\n videoRef.current.muted = true;\n try {\n await videoRef.current.play();\n } catch (retryError) {\n console.error(retryError);\n }\n }\n } else {\n console.error(error);\n }\n }\n };\n\n playVideo();\n }, [enabled, videoRef?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useAutoplayOnVisible = (\n videoRef: VideoRef,\n threshold: number | undefined,\n enabled = true\n) => {\n React.useEffect(() => {\n if (!videoRef?.current || !enabled) return;\n\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (!videoRef?.current) return;\n\n if (entry.isIntersecting) {\n videoRef.current.play().catch((error) => {\n if (!videoRef.current) return;\n\n videoRef.current.pause();\n videoRef.current.muted = true;\n videoRef.current.play();\n console.error(error);\n });\n } else {\n videoRef.current?.pause();\n }\n });\n },\n { threshold: threshold ?? 0.5 }\n );\n\n observer.observe(videoRef?.current);\n\n return () => {\n observer.disconnect();\n };\n }, [videoRef?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nconst useFullscreen = (videoRef: VideoRef) => {\n const [isFullscreen, setIsFullscreen] = React.useState(false);\n const previousStylesRef = React.useRef<{\n objectFit: string;\n borderRadius: string;\n width: string;\n height: string;\n maxWidth: string;\n maxHeight: string;\n margin: string;\n } | null>(null);\n console.log(\"storing previous styles\", previousStylesRef.current);\n\n React.useEffect(() => {\n const video = videoRef?.current;\n if (!video) return;\n\n const videoContainer = video.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement | null;\n\n // Helper to get fullscreen element with vendor prefix support\n const getFullscreenElement = (): Element | null => {\n return (\n document.fullscreenElement ||\n (document as any).webkitFullscreenElement ||\n (document as any).mozFullScreenElement ||\n (document as any).msFullscreenElement ||\n null\n );\n };\n\n const checkFullscreenState = () => {\n // Check if the container element is the fullscreen element\n const fullscreenElement = getFullscreenElement();\n const isCurrentlyFullscreen =\n !!fullscreenElement &&\n (fullscreenElement === videoContainer || fullscreenElement === video);\n\n setIsFullscreen(isCurrentlyFullscreen);\n\n // Apply styles based on fullscreen state\n if (video) {\n console.log({ isCurrentlyFullscreen });\n if (isCurrentlyFullscreen) {\n // Apply fullscreen styles\n video.style.objectFit = \"contain\";\n video.style.borderRadius = \"0\";\n video.style.width = \"100%\";\n video.style.height = \"100%\";\n video.style.maxWidth = \"none\";\n video.style.maxHeight = \"none\";\n video.style.margin = \"0\";\n } else {\n // Restore previous styles when exiting fullscreen\n if (previousStylesRef.current) {\n video.style.objectFit = previousStylesRef.current.objectFit;\n video.style.borderRadius = previousStylesRef.current.borderRadius;\n video.style.width = previousStylesRef.current.width;\n video.style.height = previousStylesRef.current.height;\n video.style.maxWidth = previousStylesRef.current.maxWidth;\n video.style.maxHeight = previousStylesRef.current.maxHeight;\n video.style.margin = previousStylesRef.current.margin;\n previousStylesRef.current = null;\n }\n }\n }\n };\n\n // Check initial state\n checkFullscreenState();\n\n // Listen for fullscreen changes\n document.addEventListener(\"fullscreenchange\", checkFullscreenState);\n\n // Also listen for vendor-prefixed events for better browser support\n document.addEventListener(\"webkitfullscreenchange\", checkFullscreenState);\n document.addEventListener(\"mozfullscreenchange\", checkFullscreenState);\n document.addEventListener(\"MSFullscreenChange\", checkFullscreenState);\n\n return () => {\n document.removeEventListener(\"fullscreenchange\", checkFullscreenState);\n document.removeEventListener(\n \"webkitfullscreenchange\",\n checkFullscreenState\n );\n document.removeEventListener(\"mozfullscreenchange\", checkFullscreenState);\n document.removeEventListener(\"MSFullscreenChange\", checkFullscreenState);\n };\n }, [videoRef]);\n\n const toggleFullscreen = () => {\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n const video = videoRef?.current;\n\n if (video && isSafari) {\n if ((video as any).webkitEnterFullscreen) {\n (video as any).webkitEnterFullscreen();\n return;\n } else if (video.requestFullscreen) {\n video.requestFullscreen();\n return;\n }\n }\n\n const videoContainer = video?.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement;\n\n if (videoContainer) {\n if (!isFullscreen) {\n console.log({ objectFit: video?.style.objectFit });\n previousStylesRef.current = {\n objectFit: video?.style.objectFit || \"\",\n borderRadius: video?.style.borderRadius || \"\",\n width: video?.style.width || \"\",\n height: video?.style.height || \"\",\n maxWidth: video?.style.maxWidth || \"\",\n maxHeight: video?.style.maxHeight || \"\",\n margin: video?.style.margin || \"\",\n };\n videoContainer.requestFullscreen();\n } else {\n document.exitFullscreen();\n }\n }\n };\n\n return { isFullscreen: isFullscreen ?? false, toggleFullscreen };\n};\n\nexport { useFullscreen };\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useGetDuration = (videoRef: VideoRef) => {\n const [isLoading, setIsLoading] = React.useState(false);\n const [duration, setDuration] = React.useState<number | null>(null);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n setIsLoading(true);\n\n const getDuration = () => {\n setDuration(videoRef.current?.duration ?? null);\n setIsLoading(false);\n };\n\n const handleError = () => {\n setIsLoading(false);\n };\n\n const video = videoRef.current;\n\n // Check if duration is already available\n if (video.duration && !isNaN(video.duration)) {\n setDuration(video.duration);\n setIsLoading(false);\n } else {\n // Add event listeners\n video.addEventListener(\"loadedmetadata\", getDuration);\n video.addEventListener(\"error\", handleError);\n video.addEventListener(\"loadeddata\", getDuration);\n\n return () => {\n video.removeEventListener(\"loadedmetadata\", getDuration);\n video.removeEventListener(\"error\", handleError);\n video.removeEventListener(\"loadeddata\", getDuration);\n };\n }\n }, [videoRef]);\n\n return { duration, isLoading };\n};\n","import { useEffect } from \"react\";\n\nexport const useHotKeys = (\n key: string,\n func: (event: KeyboardEvent) => void,\n enabled = true\n) => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === key) {\n event.preventDefault();\n func(event);\n }\n };\n\n useEffect(() => {\n if (!enabled) return;\n\n document.addEventListener(\"keydown\", handleKeyDown);\n\n return () => {\n document.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [key, func, enabled]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useMuteUnmute = (videoRef: VideoRef) => {\n const [isMuted, setIsMuted] = React.useState(false);\n\n const toggleMute = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = !videoRef.current.muted;\n }\n }, [videoRef?.current]);\n\n const mute = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = true;\n }\n }, [videoRef?.current]);\n\n const unmute = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = false;\n }\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n // Set the initial state\n setIsMuted(videoRef.current.muted);\n\n const handleVolumeChange = () => {\n if (videoRef.current) {\n setIsMuted(videoRef.current.muted);\n }\n };\n\n videoRef.current.addEventListener(\"volumechange\", handleVolumeChange);\n\n return () => {\n videoRef.current?.removeEventListener(\"volumechange\", handleVolumeChange);\n };\n }, [videoRef?.current]);\n\n return { toggleMute, isMuted, mute, unmute };\n};\n","import type { VideoRef } from \"../types\";\n\nexport const usePictureInPicture = (videoRef: VideoRef) => {\n const togglePictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n\n try {\n if (document.pictureInPictureElement) {\n await document.exitPictureInPicture();\n } else {\n await video.requestPictureInPicture();\n }\n } catch (error) {\n // Fallback for browsers that don't support PiP\n const isSafari = /^((?!chrome|android).)*safari/i.test(\n navigator.userAgent\n );\n\n if (isSafari) {\n if ((video as any).webkitEnterFullscreen) {\n (video as any).webkitEnterFullscreen();\n } else if (video.requestFullscreen) {\n video.requestFullscreen();\n }\n } else {\n const videoContainer = video.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement;\n if (videoContainer) {\n if (!document.fullscreenElement) {\n await videoContainer.requestFullscreen();\n } else {\n await document.exitFullscreen();\n }\n }\n }\n }\n };\n\n const requestPictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n await video.requestPictureInPicture();\n };\n\n const exitPictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n await document.exitPictureInPicture();\n };\n\n return {\n togglePictureInPicture,\n requestPictureInPicture,\n exitPictureInPicture,\n };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const usePlayPause = (videoRef: VideoRef) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n\n const togglePlay = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.paused\n ? videoRef.current.play()\n : videoRef.current.pause();\n }\n }, [videoRef?.current]);\n\n const play = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.play();\n }\n }, [videoRef?.current]);\n\n const pause = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.pause();\n }\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n const handlePlay = () => {\n setIsPlaying(true);\n };\n const handlePause = () => {\n setIsPlaying(false);\n };\n\n setIsPlaying(!videoRef?.current.paused);\n\n if (videoRef?.current) {\n videoRef.current.addEventListener(\"play\", handlePlay);\n videoRef.current.addEventListener(\"pause\", handlePause);\n\n return () => {\n videoRef.current?.removeEventListener(\"play\", handlePlay);\n videoRef.current?.removeEventListener(\"pause\", handlePause);\n };\n }\n }, [videoRef?.current]);\n\n return { togglePlay, isPlaying, play, pause };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useSeek = (videoRef: VideoRef, value = 10) => {\n const seekForward = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.currentTime += value;\n }\n }, [videoRef?.current]);\n\n const seekBackward = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.currentTime -= value;\n }\n }, [videoRef?.current]);\n\n return { seekForward, seekBackward };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useSpeed = (videoRef: VideoRef) => {\n const [speed, setSpeed] = React.useState(1);\n\n const onChangeSpeed = (speed: number) => {\n setSpeed(speed);\n };\n\n // Get the speed from the video element\n React.useEffect(() => {\n if (!videoRef?.current) return;\n setSpeed(videoRef.current.playbackRate);\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.playbackRate = speed;\n }, [speed, videoRef?.current]);\n\n return { speed, onChangeSpeed };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useStartAt = (videoRef: VideoRef, startAt: number) => {\n React.useEffect(() => {\n if (!videoRef?.current || !startAt) return;\n\n const video = videoRef?.current;\n if (video && startAt) {\n video.currentTime = startAt;\n }\n }, [startAt, videoRef?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types.js\";\n\nexport const useCurrentTime = (videoRef: VideoRef, interval = 10) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n const [currentTime, setCurrentTime] = React.useState(0);\n\n React.useEffect(() => {\n if (videoRef?.current && isPlaying) {\n const intervalId = setInterval(() => {\n setCurrentTime(videoRef.current?.currentTime || 0);\n }, interval);\n\n return () => clearInterval(intervalId);\n }\n }, [videoRef?.current, isPlaying]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n const video = videoRef.current;\n\n // Store handlers in variables for proper cleanup (critical for Safari memory safety)\n const handlePlay = () => setIsPlaying(true);\n const handlePause = () => setIsPlaying(false);\n\n video.addEventListener(\"play\", handlePlay);\n video.addEventListener(\"pause\", handlePause);\n\n return () => {\n video.removeEventListener(\"play\", handlePlay);\n video.removeEventListener(\"pause\", handlePause);\n };\n }, [videoRef?.current]);\n\n const onTimeUpdate = (time: number) => {\n if (videoRef?.current) {\n setCurrentTime(time);\n videoRef.current.currentTime = time;\n }\n };\n\n return {\n currentTime,\n onTimeUpdate,\n };\n};\n","import { RefObject, useEffect, useState } from \"react\";\n\nconst useVideoState = (videoRef: RefObject<HTMLVideoElement | null>) => {\n const [isPlaying, setIsPlaying] = useState(false);\n const [isMuted, setIsMuted] = useState(false);\n const [isFullscreen, setIsFullscreen] = useState(false);\n\n useEffect(() => {\n const video = videoRef.current;\n\n if (video) {\n video.addEventListener(\"play\", () => setIsPlaying(true));\n video.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n video.removeEventListener(\"play\", () => setIsPlaying(true));\n video.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }\n }, [videoRef]);\n\n useEffect(() => {\n if (!videoRef?.current) return;\n\n // Set the initial state\n setIsMuted(videoRef.current.muted);\n\n const handleVolumeChange = () => {\n if (videoRef.current) {\n setIsMuted(videoRef.current.muted);\n }\n };\n\n videoRef.current.addEventListener(\"volumechange\", handleVolumeChange);\n\n return () => {\n videoRef.current?.removeEventListener(\"volumechange\", handleVolumeChange);\n };\n }, [videoRef]);\n\n useEffect(() => {\n if (!videoRef?.current) return;\n\n const handleFullscreenChange = () => {\n setIsFullscreen(!!document.fullscreenElement);\n };\n\n document.addEventListener(\"fullscreenchange\", handleFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", handleFullscreenChange);\n }, [videoRef]);\n\n return { isPlaying, isMuted, isFullscreen };\n};\n\nexport { useVideoState };\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useVolume = (videoRef: VideoRef, initialVolume = 100) => {\n const [volume, setVolume] = React.useState(initialVolume);\n\n const onChangeVolume = (volume: number) => {\n setVolume(volume);\n };\n\n // Get the volume from the video element\n React.useEffect(() => {\n if (!videoRef?.current) return;\n setVolume(videoRef.current.volume * 100);\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.volume = volume / 100;\n }, [volume, videoRef?.current]);\n\n return { volume, onChangeVolume };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types.js\";\n\nexport const useBuffer = (videoRef: VideoRef, duration?: number) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n const [buffered, setBuffered] = React.useState(0);\n\n React.useEffect(() => {\n if (videoRef?.current && isPlaying) {\n const intervalId = setInterval(() => {\n if (videoRef.current?.buffered.length) {\n setBuffered(\n videoRef.current.buffered.end(videoRef.current.buffered.length - 1)\n );\n }\n }, 10);\n\n return () => clearInterval(intervalId);\n }\n }, [videoRef?.current, isPlaying]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.addEventListener(\"play\", () => setIsPlaying(true));\n videoRef.current.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n videoRef.current?.removeEventListener(\"play\", () => setIsPlaying(true));\n videoRef.current?.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }, []);\n\n return {\n buffered,\n bufferedPercentage: (buffered / (duration || 0)) * 100 || 0,\n };\n};\n","import { useEffect, useState, useCallback } from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useDownload = (videoRef: VideoRef) => {\n const [isDownloading, setIsDownloading] = useState(false);\n const [downloadProgress, setDownloadProgress] = useState(0);\n const [error, setError] = useState<string | null>(null);\n\n const downloadVideo = useCallback(\n async (filename?: string) => {\n if (!videoRef?.current) {\n setError(\"Video element not found\");\n return;\n }\n\n const video = videoRef.current;\n const videoSrc = video.src || video.currentSrc;\n\n if (!videoSrc) {\n setError(\"No video source found\");\n return;\n }\n\n try {\n setIsDownloading(true);\n setError(null);\n setDownloadProgress(0);\n\n // Fetch the video file\n const response = await fetch(videoSrc);\n\n if (!response.ok) {\n throw new Error(`Failed to fetch video: ${response.statusText}`);\n }\n\n // Get the content length for progress tracking\n const contentLength = response.headers.get(\"content-length\");\n const total = contentLength ? parseInt(contentLength, 10) : 0;\n\n // Create a readable stream to track progress\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error(\"Failed to create download stream\");\n }\n\n const chunks: BlobPart[] = [];\n let receivedLength = 0;\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) break;\n\n chunks.push(value);\n receivedLength += value.length;\n\n if (total > 0) {\n const progress = (receivedLength / total) * 100;\n setDownloadProgress(Math.round(progress));\n }\n }\n\n // Combine chunks into a single blob\n const blob = new Blob(chunks, {\n type: response.headers.get(\"content-type\") || \"video/mp4\",\n });\n\n // Create download link\n const url = URL.createObjectURL(blob);\n const link = document.createElement(\"a\");\n link.href = url;\n\n // Generate filename if not provided\n const defaultFilename = filename || `video-${Date.now()}.mp4`;\n link.download = defaultFilename;\n\n // Trigger download\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n\n // Clean up\n URL.revokeObjectURL(url);\n\n setDownloadProgress(100);\n setIsDownloading(false);\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Download failed\");\n setIsDownloading(false);\n setDownloadProgress(0);\n }\n },\n [videoRef]\n );\n\n // Alternative simple download method for direct video URLs\n const downloadDirect = useCallback(\n (filename?: string) => {\n if (!videoRef?.current) {\n setError(\"Video element not found\");\n return;\n }\n\n const video = videoRef.current;\n const videoSrc = video.src || video.currentSrc;\n\n if (!videoSrc) {\n setError(\"No video source found\");\n return;\n }\n\n try {\n setIsDownloading(true);\n setError(null);\n setDownloadProgress(0);\n\n const link = document.createElement(\"a\");\n link.href = videoSrc;\n link.download = filename || `video-${Date.now()}.mp4`;\n link.target = \"_blank\";\n\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n\n setIsDownloading(false);\n setDownloadProgress(100);\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Download failed\");\n setIsDownloading(false);\n setDownloadProgress(0);\n }\n },\n [videoRef]\n );\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n setIsDownloading(false);\n setDownloadProgress(0);\n setError(null);\n };\n }, []);\n\n return {\n downloadVideo,\n downloadDirect,\n isDownloading,\n downloadProgress,\n error,\n resetError: () => setError(null),\n };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useRange = (videoRef: VideoRef, range: [number, number]) => {\n React.useEffect(() => {\n if (!videoRef?.current || !range) return;\n\n const video = videoRef.current;\n\n if (video) {\n const handleTimeUpdate = () => {\n if (video.currentTime >= range[1]) {\n video.currentTime = range[0];\n } else if (video.currentTime <= range[0]) {\n video.currentTime = range[0];\n }\n };\n\n video.addEventListener(\"timeupdate\", handleTimeUpdate);\n\n return () => {\n video.removeEventListener(\"timeupdate\", handleTimeUpdate);\n };\n }\n }, [range, videoRef?.current]);\n};\n"],"mappings":"AAAA,OAAOA,MAAW,QAGX,IAAMC,EAAqB,CAChCC,EACAC,EACAC,IACG,CACHJ,EAAM,UAAU,IAAM,CACpB,GAAI,EAACE,GAAA,MAAAA,EAAU,UAAW,CAACC,EAAS,QAElB,SAAY,CAXlC,IAAAE,EAYM,GAAI,CACF,OAAMA,EAAAH,EAAS,UAAT,YAAAG,EAAkB,OAC1B,OAASC,EAAO,CAEd,GAAIA,aAAiB,OAASA,EAAM,OAAS,mBAG3C,GAFAF,GAAA,MAAAA,EAAW,mBACX,QAAQ,MAAM,iBAAiB,EAC3BF,GAAA,MAAAA,EAAU,QAAS,CACrBA,EAAS,QAAQ,MAAQ,GACzB,GAAI,CACF,MAAMA,EAAS,QAAQ,KAAK,CAC9B,OAASK,EAAY,CACnB,QAAQ,MAAMA,CAAU,CAC1B,CACF,OAEA,QAAQ,MAAMD,CAAK,CAEvB,CACF,GAEU,CACZ,EAAG,CAACH,EAASD,GAAA,YAAAA,EAAU,OAAO,CAAC,CACjC,ECnCA,OAAOM,MAAW,QAGX,IAAMC,EAAuB,CAClCC,EACAC,EACAC,EAAU,KACP,CACHJ,EAAM,UAAU,IAAM,CACpB,GAAI,EAACE,GAAA,MAAAA,EAAU,UAAW,CAACE,EAAS,OAEpC,IAAMC,EAAW,IAAI,qBAClBC,GAAY,CACXA,EAAQ,QAASC,GAAU,CAbn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AU,OAAO,CAAC,CAC/B","names":["React","useAutoplayByForce","videoRef","enabled","setError","_a","error","retryError","React","useAutoplayOnVisible","videoRef","threshold","enabled","observer","entries","entry","_a","error","React","useFullscreen","videoRef","isFullscreen","setIsFullscreen","previousStylesRef","video","videoContainer","getFullscreenElement","checkFullscreenState","fullscreenElement","isCurrentlyFullscreen","toggleFullscreen","isSafari","React","useGetDuration","videoRef","isLoading","setIsLoading","duration","setDuration","getDuration","_a","_b","handleError","video","useEffect","useHotKeys","key","func","enabled","handleKeyDown","event","React","useMuteUnmute","videoRef","isMuted","setIsMuted","toggleMute","mute","unmute","handleVolumeChange","_a","usePictureInPicture","videoRef","video","error","videoContainer","React","usePlayPause","videoRef","isPlaying","setIsPlaying","togglePlay","play","pause","handlePlay","handlePause","_a","_b","React","useSeek","videoRef","value","seekForward","seekBackward","React","useSpeed","videoRef","speed","setSpeed","onChangeSpeed","React","useStartAt","videoRef","startAt","video","React","useCurrentTime","videoRef","interval","isPlaying","setIsPlaying","currentTime","setCurrentTime","intervalId","_a","video","handlePlay","handlePause","time","useEffect","useState","useVideoState","videoRef","isPlaying","setIsPlaying","isMuted","setIsMuted","isFullscreen","setIsFullscreen","video","handleVolumeChange","_a","handleFullscreenChange","React","useVolume","videoRef","initialVolume","volume","setVolume","onChangeVolume","React","useBuffer","videoRef","duration","isPlaying","setIsPlaying","buffered","setBuffered","intervalId","_a","_b","useEffect","useState","useCallback","useDownload","videoRef","isDownloading","setIsDownloading","downloadProgress","setDownloadProgress","error","setError","downloadVideo","filename","_a","video","videoSrc","response","contentLength","total","reader","chunks","receivedLength","done","value","progress","blob","url","link","defaultFilename","err","downloadDirect","React","useRange","videoRef","range","video","handleTimeUpdate"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import K from"react";var Q=(t,e,n)=>{K.useEffect(()=>{if(!(t!=null&&t.current)||!e)return;(async()=>{var u;try{await((u=t.current)==null?void 0:u.play())}catch(a){if(a instanceof Error&&a.name==="NotAllowedError"){if(n==null||n("NotAllowedError"),console.error("NotAllowedError"),t!=null&&t.current){t.current.muted=!0;try{await t.current.play()}catch(s){console.error(s)}}}else console.error(a)}})()},[e,t==null?void 0:t.current])};import W from"react";var Z=(t,e,n=!0)=>{W.useEffect(()=>{if(!(t!=null&&t.current)||!n)return;let c=new IntersectionObserver(u=>{u.forEach(a=>{var s;t!=null&&t.current&&(a.isIntersecting?t.current.play().catch(r=>{t.current&&(t.current.pause(),t.current.muted=!0,t.current.play(),console.error(r))}):(s=t.current)==null||s.pause())})},{threshold:e!=null?e:.5});return c.observe(t==null?void 0:t.current),()=>{c.disconnect()}},[t==null?void 0:t.current])};import L from"react";var v=t=>{let[e,n]=L.useState(!1),c=L.useRef(null);L.useEffect(()=>{let a=()=>{let s=!!document.fullscreenElement;n(s);let r=t==null?void 0:t.current;r&&s&&(c.current={objectFit:r.style.objectFit||"cover",borderRadius:r.style.borderRadius||"",width:r.style.width||"",height:r.style.height||"",maxWidth:r.style.maxWidth||"",maxHeight:r.style.maxHeight||"",margin:r.style.margin||""},r.style.objectFit="contain",r.style.borderRadius="0",r.style.width="100%",r.style.height="100%",r.style.maxWidth="none",r.style.maxHeight="none",r.style.margin="0")};return document.addEventListener("fullscreenchange",a),()=>document.removeEventListener("fullscreenchange",a)},[t]);let u=()=>{let a=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),s=t==null?void 0:t.current;if(s&&a){if(s.webkitEnterFullscreen){s.webkitEnterFullscreen();return}else if(s.requestFullscreen){s.requestFullscreen();return}}let r=s==null?void 0:s.closest("[data-zuude-video-wrapper]");r&&(e?document.exitFullscreen():r.requestFullscreen())};return{isFullscreen:e!=null?e:!1,toggleFullscreen:u}};import V from"react";var rt=t=>{let[e,n]=V.useState(!1),[c,u]=V.useState(null);return V.useEffect(()=>{if(!(t!=null&&t.current))return;n(!0);let a=()=>{var l,m;u((m=(l=t.current)==null?void 0:l.duration)!=null?m:null),n(!1)},s=()=>{n(!1)},r=t.current;if(r.duration&&!isNaN(r.duration))u(r.duration),n(!1);else return r.addEventListener("loadedmetadata",a),r.addEventListener("error",s),r.addEventListener("loadeddata",a),()=>{r.removeEventListener("loadedmetadata",a),r.removeEventListener("error",s),r.removeEventListener("loadeddata",a)}},[t]),{duration:c,isLoading:e}};import{useEffect as $}from"react";var ut=(t,e,n=!0)=>{let c=u=>{u.key===t&&(u.preventDefault(),e(u))};$(()=>{if(n)return document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c)}},[t,e,n])};import h from"react";var at=t=>{let[e,n]=h.useState(!1),c=h.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!t.current.muted)},[t==null?void 0:t.current]),u=h.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!0)},[t==null?void 0:t.current]),a=h.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!1)},[t==null?void 0:t.current]);return h.useEffect(()=>{if(!(t!=null&&t.current))return;n(t.current.muted);let s=()=>{t.current&&n(t.current.muted)};return t.current.addEventListener("volumechange",s),()=>{var r;(r=t.current)==null||r.removeEventListener("volumechange",s)}},[t==null?void 0:t.current]),{toggleMute:c,isMuted:e,mute:u,unmute:a}};var mt=t=>({togglePictureInPicture:async()=>{let u=t==null?void 0:t.current;if(u)try{document.pictureInPictureElement?await document.exitPictureInPicture():await u.requestPictureInPicture()}catch(a){if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))u.webkitEnterFullscreen?u.webkitEnterFullscreen():u.requestFullscreen&&u.requestFullscreen();else{let r=u.closest("[data-zuude-video-wrapper]");r&&(document.fullscreenElement?await document.exitFullscreen():await r.requestFullscreen())}}},requestPictureInPicture:async()=>{let u=t==null?void 0:t.current;u&&await u.requestPictureInPicture()},exitPictureInPicture:async()=>{t!=null&&t.current&&await document.exitPictureInPicture()}});import b from"react";var yt=t=>{let[e,n]=b.useState(!1),c=b.useCallback(()=>{t!=null&&t.current&&(t.current.paused?t.current.play():t.current.pause())},[t==null?void 0:t.current]),u=b.useCallback(()=>{t!=null&&t.current&&t.current.play()},[t==null?void 0:t.current]),a=b.useCallback(()=>{t!=null&&t.current&&t.current.pause()},[t==null?void 0:t.current]);return b.useEffect(()=>{if(!(t!=null&&t.current))return;let s=()=>{n(!0)},r=()=>{n(!1)};if(n(!(t!=null&&t.current.paused)),t!=null&&t.current)return t.current.addEventListener("play",s),t.current.addEventListener("pause",r),()=>{var l,m;(l=t.current)==null||l.removeEventListener("play",s),(m=t.current)==null||m.removeEventListener("pause",r)}},[t==null?void 0:t.current]),{togglePlay:c,isPlaying:e,play:u,pause:a}};import H from"react";var ht=(t,e=10)=>{let n=H.useCallback(()=>{t!=null&&t.current&&(t.current.currentTime+=e)},[t==null?void 0:t.current]),c=H.useCallback(()=>{t!=null&&t.current&&(t.current.currentTime-=e)},[t==null?void 0:t.current]);return{seekForward:n,seekBackward:c}};import P from"react";var xt=t=>{let[e,n]=P.useState(1),c=u=>{n(u)};return P.useEffect(()=>{t!=null&&t.current&&n(t.current.playbackRate)},[t==null?void 0:t.current]),P.useEffect(()=>{t!=null&&t.current&&(t.current.playbackRate=e)},[e,t==null?void 0:t.current]),{speed:e,onChangeSpeed:c}};import z from"react";var Pt=(t,e)=>{z.useEffect(()=>{if(!(t!=null&&t.current)||!e)return;let n=t==null?void 0:t.current;n&&e&&(n.currentTime=e)},[e,t==null?void 0:t.current])};import w from"react";var Ft=(t,e=10)=>{let[n,c]=w.useState(!1),[u,a]=w.useState(0);return w.useEffect(()=>{if(t!=null&&t.current&&n){let r=setInterval(()=>{var l;a(((l=t.current)==null?void 0:l.currentTime)||0)},e);return()=>clearInterval(r)}},[t==null?void 0:t.current,n]),w.useEffect(()=>{if(!(t!=null&&t.current))return;let r=t.current,l=()=>c(!0),m=()=>c(!1);return r.addEventListener("play",l),r.addEventListener("pause",m),()=>{r.removeEventListener("play",l),r.removeEventListener("pause",m)}},[t==null?void 0:t.current]),{currentTime:u,onTimeUpdate:r=>{t!=null&&t.current&&(a(r),t.current.currentTime=r)}}};import{useEffect as I,useState as k}from"react";var Tt=t=>{let[e,n]=k(!1),[c,u]=k(!1),[a,s]=k(!1);return I(()=>{let r=t.current;if(r)return r.addEventListener("play",()=>n(!0)),r.addEventListener("pause",()=>n(!1)),()=>{r.removeEventListener("play",()=>n(!0)),r.removeEventListener("pause",()=>n(!1))}},[t]),I(()=>{if(!(t!=null&&t.current))return;u(t.current.muted);let r=()=>{t.current&&u(t.current.muted)};return t.current.addEventListener("volumechange",r),()=>{var l;(l=t.current)==null||l.removeEventListener("volumechange",r)}},[t]),I(()=>{if(!(t!=null&&t.current))return;let r=()=>{s(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",r),()=>document.removeEventListener("fullscreenchange",r)},[t]),{isPlaying:e,isMuted:c,isFullscreen:a}};import F from"react";var qt=(t,e=100)=>{let[n,c]=F.useState(e),u=a=>{c(a)};return F.useEffect(()=>{t!=null&&t.current&&c(t.current.volume*100)},[t==null?void 0:t.current]),F.useEffect(()=>{t!=null&&t.current&&(t.current.volume=n/100)},[n,t==null?void 0:t.current]),{volume:n,onChangeVolume:u}};import x from"react";var Ut=(t,e)=>{let[n,c]=x.useState(!1),[u,a]=x.useState(0);return x.useEffect(()=>{if(t!=null&&t.current&&n){let s=setInterval(()=>{var r;(r=t.current)!=null&&r.buffered.length&&a(t.current.buffered.end(t.current.buffered.length-1))},10);return()=>clearInterval(s)}},[t==null?void 0:t.current,n]),x.useEffect(()=>{if(t!=null&&t.current)return t.current.addEventListener("play",()=>c(!0)),t.current.addEventListener("pause",()=>c(!1)),()=>{var s,r;(s=t.current)==null||s.removeEventListener("play",()=>c(!0)),(r=t.current)==null||r.removeEventListener("pause",()=>c(!1))}},[]),{buffered:u,bufferedPercentage:u/(e||0)*100||0}};import{useEffect as G,useState as S,useCallback as U}from"react";var Ot=t=>{let[e,n]=S(!1),[c,u]=S(0),[a,s]=S(null),r=U(async m=>{var p;if(!(t!=null&&t.current)){s("Video element not found");return}let y=t.current,g=y.src||y.currentSrc;if(!g){s("No video source found");return}try{n(!0),s(null),u(0);let o=await fetch(g);if(!o.ok)throw new Error(`Failed to fetch video: ${o.statusText}`);let i=o.headers.get("content-length"),C=i?parseInt(i,10):0,T=(p=o.body)==null?void 0:p.getReader();if(!T)throw new Error("Failed to create download stream");let D=[],j=0;for(;;){let{done:O,value:M}=await T.read();if(O)break;if(D.push(M),j+=M.length,C>0){let A=j/C*100;u(Math.round(A))}}let N=new Blob(D,{type:o.headers.get("content-type")||"video/mp4"}),q=URL.createObjectURL(N),E=document.createElement("a");E.href=q;let B=m||`video-${Date.now()}.mp4`;E.download=B,document.body.appendChild(E),E.click(),document.body.removeChild(E),URL.revokeObjectURL(q),u(100),n(!1)}catch(o){s(o instanceof Error?o.message:"Download failed"),n(!1),u(0)}},[t]),l=U(m=>{if(!(t!=null&&t.current)){s("Video element not found");return}let y=t.current,g=y.src||y.currentSrc;if(!g){s("No video source found");return}try{n(!0),s(null),u(0);let p=document.createElement("a");p.href=g,p.download=m||`video-${Date.now()}.mp4`,p.target="_blank",document.body.appendChild(p),p.click(),document.body.removeChild(p),n(!1),u(100)}catch(p){s(p instanceof Error?p.message:"Download failed"),n(!1),u(0)}},[t]);return G(()=>()=>{n(!1),u(0),s(null)},[]),{downloadVideo:r,downloadDirect:l,isDownloading:e,downloadProgress:c,error:a,resetError:()=>s(null)}};import _ from"react";var Wt=(t,e)=>{_.useEffect(()=>{if(!(t!=null&&t.current)||!e)return;let n=t.current;if(n){let c=()=>{(n.currentTime>=e[1]||n.currentTime<=e[0])&&(n.currentTime=e[0])};return n.addEventListener("timeupdate",c),()=>{n.removeEventListener("timeupdate",c)}}},[e,t==null?void 0:t.current])};export{Q as a,ut as b,ht as c,yt as d,at as e,v as f,mt as g,Z as h,rt as i,xt as j,Pt as k,Ft as l,Tt as m,qt as n,Ut as o,Ot as p,Wt as q};
|
|
2
|
+
//# sourceMappingURL=chunk-ZDOBNBGL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-autoplay-by-force.tsx","../src/hooks/use-autoplay-on-visible.tsx","../src/hooks/use-fullscreen.tsx","../src/hooks/use-get-duration.tsx","../src/hooks/use-hot-keys.tsx","../src/hooks/use-mute-unmute.tsx","../src/hooks/use-picture-in-picture.tsx","../src/hooks/use-play-pause.tsx","../src/hooks/use-seek.tsx","../src/hooks/use-speed.tsx","../src/hooks/use-start-at.tsx","../src/hooks/use-current-time.tsx","../src/hooks/use-video-state.tsx","../src/hooks/use-volume.tsx","../src/hooks/use-buffer.tsx","../src/hooks/use-download.tsx","../src/hooks/use-range.tsx"],"sourcesContent":["import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useAutoplayByForce = (\n videoRef: VideoRef,\n enabled: boolean,\n setError?: (error: string | null) => void\n) => {\n React.useEffect(() => {\n if (!videoRef?.current || !enabled) return;\n\n const playVideo = async () => {\n try {\n await videoRef.current?.play();\n } catch (error) {\n // If autoplay fails, try muting and playing again\n if (error instanceof Error && error.name === \"NotAllowedError\") {\n setError?.(\"NotAllowedError\");\n console.error(\"NotAllowedError\");\n if (videoRef?.current) {\n videoRef.current.muted = true;\n try {\n await videoRef.current.play();\n } catch (retryError) {\n console.error(retryError);\n }\n }\n } else {\n console.error(error);\n }\n }\n };\n\n playVideo();\n }, [enabled, videoRef?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useAutoplayOnVisible = (\n videoRef: VideoRef,\n threshold: number | undefined,\n enabled = true\n) => {\n React.useEffect(() => {\n if (!videoRef?.current || !enabled) return;\n\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (!videoRef?.current) return;\n\n if (entry.isIntersecting) {\n videoRef.current.play().catch((error) => {\n if (!videoRef.current) return;\n\n videoRef.current.pause();\n videoRef.current.muted = true;\n videoRef.current.play();\n console.error(error);\n });\n } else {\n videoRef.current?.pause();\n }\n });\n },\n { threshold: threshold ?? 0.5 }\n );\n\n observer.observe(videoRef?.current);\n\n return () => {\n observer.disconnect();\n };\n }, [videoRef?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nconst useFullscreen = (videoRef: VideoRef) => {\n const [isFullscreen, setIsFullscreen] = React.useState(false);\n const previousStylesRef = React.useRef<{\n objectFit: string;\n borderRadius: string;\n width: string;\n height: string;\n maxWidth: string;\n maxHeight: string;\n margin: string;\n } | null>(null);\n\n React.useEffect(() => {\n const handleFullscreenChange = () => {\n const isCurrentlyFullscreen = !!document.fullscreenElement;\n setIsFullscreen(isCurrentlyFullscreen);\n\n // Apply styles based on fullscreen state\n const video = videoRef?.current;\n if (video) {\n if (isCurrentlyFullscreen) {\n // Store previous styles before entering fullscreen\n previousStylesRef.current = {\n objectFit: video.style.objectFit || \"cover\",\n borderRadius: video.style.borderRadius || \"\",\n width: video.style.width || \"\",\n height: video.style.height || \"\",\n maxWidth: video.style.maxWidth || \"\",\n maxHeight: video.style.maxHeight || \"\",\n margin: video.style.margin || \"\",\n };\n // Apply fullscreen styles\n video.style.objectFit = \"contain\";\n video.style.borderRadius = \"0\";\n video.style.width = \"100%\";\n video.style.height = \"100%\";\n video.style.maxWidth = \"none\";\n video.style.maxHeight = \"none\";\n video.style.margin = \"0\";\n } else {\n // Restore previous styles when exiting fullscreen\n // if (previousStylesRef.current) {\n // video.style.objectFit = previousStylesRef.current.objectFit;\n // video.style.borderRadius = previousStylesRef.current.borderRadius;\n // video.style.width = previousStylesRef.current.width;\n // video.style.height = previousStylesRef.current.height;\n // video.style.maxWidth = previousStylesRef.current.maxWidth;\n // video.style.maxHeight = previousStylesRef.current.maxHeight;\n // video.style.margin = previousStylesRef.current.margin;\n // previousStylesRef.current = null;\n // }\n }\n }\n };\n\n document.addEventListener(\"fullscreenchange\", handleFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", handleFullscreenChange);\n }, [videoRef]);\n\n const toggleFullscreen = () => {\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n const video = videoRef?.current;\n\n if (video && isSafari) {\n if ((video as any).webkitEnterFullscreen) {\n (video as any).webkitEnterFullscreen();\n return;\n } else if (video.requestFullscreen) {\n video.requestFullscreen();\n return;\n }\n }\n\n const videoContainer = video?.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement;\n\n if (videoContainer) {\n if (!isFullscreen) {\n videoContainer.requestFullscreen();\n } else {\n document.exitFullscreen();\n }\n }\n };\n\n return { isFullscreen: isFullscreen ?? false, toggleFullscreen };\n};\n\nexport { useFullscreen };\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useGetDuration = (videoRef: VideoRef) => {\n const [isLoading, setIsLoading] = React.useState(false);\n const [duration, setDuration] = React.useState<number | null>(null);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n setIsLoading(true);\n\n const getDuration = () => {\n setDuration(videoRef.current?.duration ?? null);\n setIsLoading(false);\n };\n\n const handleError = () => {\n setIsLoading(false);\n };\n\n const video = videoRef.current;\n\n // Check if duration is already available\n if (video.duration && !isNaN(video.duration)) {\n setDuration(video.duration);\n setIsLoading(false);\n } else {\n // Add event listeners\n video.addEventListener(\"loadedmetadata\", getDuration);\n video.addEventListener(\"error\", handleError);\n video.addEventListener(\"loadeddata\", getDuration);\n\n return () => {\n video.removeEventListener(\"loadedmetadata\", getDuration);\n video.removeEventListener(\"error\", handleError);\n video.removeEventListener(\"loadeddata\", getDuration);\n };\n }\n }, [videoRef]);\n\n return { duration, isLoading };\n};\n","import { useEffect } from \"react\";\n\nexport const useHotKeys = (\n key: string,\n func: (event: KeyboardEvent) => void,\n enabled = true\n) => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === key) {\n event.preventDefault();\n func(event);\n }\n };\n\n useEffect(() => {\n if (!enabled) return;\n\n document.addEventListener(\"keydown\", handleKeyDown);\n\n return () => {\n document.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [key, func, enabled]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useMuteUnmute = (videoRef: VideoRef) => {\n const [isMuted, setIsMuted] = React.useState(false);\n\n const toggleMute = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = !videoRef.current.muted;\n }\n }, [videoRef?.current]);\n\n const mute = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = true;\n }\n }, [videoRef?.current]);\n\n const unmute = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = false;\n }\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n // Set the initial state\n setIsMuted(videoRef.current.muted);\n\n const handleVolumeChange = () => {\n if (videoRef.current) {\n setIsMuted(videoRef.current.muted);\n }\n };\n\n videoRef.current.addEventListener(\"volumechange\", handleVolumeChange);\n\n return () => {\n videoRef.current?.removeEventListener(\"volumechange\", handleVolumeChange);\n };\n }, [videoRef?.current]);\n\n return { toggleMute, isMuted, mute, unmute };\n};\n","import type { VideoRef } from \"../types\";\n\nexport const usePictureInPicture = (videoRef: VideoRef) => {\n const togglePictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n\n try {\n if (document.pictureInPictureElement) {\n await document.exitPictureInPicture();\n } else {\n await video.requestPictureInPicture();\n }\n } catch (error) {\n // Fallback for browsers that don't support PiP\n const isSafari = /^((?!chrome|android).)*safari/i.test(\n navigator.userAgent\n );\n\n if (isSafari) {\n if ((video as any).webkitEnterFullscreen) {\n (video as any).webkitEnterFullscreen();\n } else if (video.requestFullscreen) {\n video.requestFullscreen();\n }\n } else {\n const videoContainer = video.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement;\n if (videoContainer) {\n if (!document.fullscreenElement) {\n await videoContainer.requestFullscreen();\n } else {\n await document.exitFullscreen();\n }\n }\n }\n }\n };\n\n const requestPictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n await video.requestPictureInPicture();\n };\n\n const exitPictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n await document.exitPictureInPicture();\n };\n\n return {\n togglePictureInPicture,\n requestPictureInPicture,\n exitPictureInPicture,\n };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const usePlayPause = (videoRef: VideoRef) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n\n const togglePlay = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.paused\n ? videoRef.current.play()\n : videoRef.current.pause();\n }\n }, [videoRef?.current]);\n\n const play = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.play();\n }\n }, [videoRef?.current]);\n\n const pause = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.pause();\n }\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n const handlePlay = () => {\n setIsPlaying(true);\n };\n const handlePause = () => {\n setIsPlaying(false);\n };\n\n setIsPlaying(!videoRef?.current.paused);\n\n if (videoRef?.current) {\n videoRef.current.addEventListener(\"play\", handlePlay);\n videoRef.current.addEventListener(\"pause\", handlePause);\n\n return () => {\n videoRef.current?.removeEventListener(\"play\", handlePlay);\n videoRef.current?.removeEventListener(\"pause\", handlePause);\n };\n }\n }, [videoRef?.current]);\n\n return { togglePlay, isPlaying, play, pause };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useSeek = (videoRef: VideoRef, value = 10) => {\n const seekForward = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.currentTime += value;\n }\n }, [videoRef?.current]);\n\n const seekBackward = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.currentTime -= value;\n }\n }, [videoRef?.current]);\n\n return { seekForward, seekBackward };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useSpeed = (videoRef: VideoRef) => {\n const [speed, setSpeed] = React.useState(1);\n\n const onChangeSpeed = (speed: number) => {\n setSpeed(speed);\n };\n\n // Get the speed from the video element\n React.useEffect(() => {\n if (!videoRef?.current) return;\n setSpeed(videoRef.current.playbackRate);\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.playbackRate = speed;\n }, [speed, videoRef?.current]);\n\n return { speed, onChangeSpeed };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useStartAt = (videoRef: VideoRef, startAt: number) => {\n React.useEffect(() => {\n if (!videoRef?.current || !startAt) return;\n\n const video = videoRef?.current;\n if (video && startAt) {\n video.currentTime = startAt;\n }\n }, [startAt, videoRef?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types.js\";\n\nexport const useCurrentTime = (videoRef: VideoRef, interval = 10) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n const [currentTime, setCurrentTime] = React.useState(0);\n\n React.useEffect(() => {\n if (videoRef?.current && isPlaying) {\n const intervalId = setInterval(() => {\n setCurrentTime(videoRef.current?.currentTime || 0);\n }, interval);\n\n return () => clearInterval(intervalId);\n }\n }, [videoRef?.current, isPlaying]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n const video = videoRef.current;\n\n // Store handlers in variables for proper cleanup (critical for Safari memory safety)\n const handlePlay = () => setIsPlaying(true);\n const handlePause = () => setIsPlaying(false);\n\n video.addEventListener(\"play\", handlePlay);\n video.addEventListener(\"pause\", handlePause);\n\n return () => {\n video.removeEventListener(\"play\", handlePlay);\n video.removeEventListener(\"pause\", handlePause);\n };\n }, [videoRef?.current]);\n\n const onTimeUpdate = (time: number) => {\n if (videoRef?.current) {\n setCurrentTime(time);\n videoRef.current.currentTime = time;\n }\n };\n\n return {\n currentTime,\n onTimeUpdate,\n };\n};\n","import { RefObject, useEffect, useState } from \"react\";\n\nconst useVideoState = (videoRef: RefObject<HTMLVideoElement | null>) => {\n const [isPlaying, setIsPlaying] = useState(false);\n const [isMuted, setIsMuted] = useState(false);\n const [isFullscreen, setIsFullscreen] = useState(false);\n\n useEffect(() => {\n const video = videoRef.current;\n\n if (video) {\n video.addEventListener(\"play\", () => setIsPlaying(true));\n video.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n video.removeEventListener(\"play\", () => setIsPlaying(true));\n video.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }\n }, [videoRef]);\n\n useEffect(() => {\n if (!videoRef?.current) return;\n\n // Set the initial state\n setIsMuted(videoRef.current.muted);\n\n const handleVolumeChange = () => {\n if (videoRef.current) {\n setIsMuted(videoRef.current.muted);\n }\n };\n\n videoRef.current.addEventListener(\"volumechange\", handleVolumeChange);\n\n return () => {\n videoRef.current?.removeEventListener(\"volumechange\", handleVolumeChange);\n };\n }, [videoRef]);\n\n useEffect(() => {\n if (!videoRef?.current) return;\n\n const handleFullscreenChange = () => {\n setIsFullscreen(!!document.fullscreenElement);\n };\n\n document.addEventListener(\"fullscreenchange\", handleFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", handleFullscreenChange);\n }, [videoRef]);\n\n return { isPlaying, isMuted, isFullscreen };\n};\n\nexport { useVideoState };\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useVolume = (videoRef: VideoRef, initialVolume = 100) => {\n const [volume, setVolume] = React.useState(initialVolume);\n\n const onChangeVolume = (volume: number) => {\n setVolume(volume);\n };\n\n // Get the volume from the video element\n React.useEffect(() => {\n if (!videoRef?.current) return;\n setVolume(videoRef.current.volume * 100);\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.volume = volume / 100;\n }, [volume, videoRef?.current]);\n\n return { volume, onChangeVolume };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types.js\";\n\nexport const useBuffer = (videoRef: VideoRef, duration?: number) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n const [buffered, setBuffered] = React.useState(0);\n\n React.useEffect(() => {\n if (videoRef?.current && isPlaying) {\n const intervalId = setInterval(() => {\n if (videoRef.current?.buffered.length) {\n setBuffered(\n videoRef.current.buffered.end(videoRef.current.buffered.length - 1)\n );\n }\n }, 10);\n\n return () => clearInterval(intervalId);\n }\n }, [videoRef?.current, isPlaying]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.addEventListener(\"play\", () => setIsPlaying(true));\n videoRef.current.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n videoRef.current?.removeEventListener(\"play\", () => setIsPlaying(true));\n videoRef.current?.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }, []);\n\n return {\n buffered,\n bufferedPercentage: (buffered / (duration || 0)) * 100 || 0,\n };\n};\n","import { useEffect, useState, useCallback } from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useDownload = (videoRef: VideoRef) => {\n const [isDownloading, setIsDownloading] = useState(false);\n const [downloadProgress, setDownloadProgress] = useState(0);\n const [error, setError] = useState<string | null>(null);\n\n const downloadVideo = useCallback(\n async (filename?: string) => {\n if (!videoRef?.current) {\n setError(\"Video element not found\");\n return;\n }\n\n const video = videoRef.current;\n const videoSrc = video.src || video.currentSrc;\n\n if (!videoSrc) {\n setError(\"No video source found\");\n return;\n }\n\n try {\n setIsDownloading(true);\n setError(null);\n setDownloadProgress(0);\n\n // Fetch the video file\n const response = await fetch(videoSrc);\n\n if (!response.ok) {\n throw new Error(`Failed to fetch video: ${response.statusText}`);\n }\n\n // Get the content length for progress tracking\n const contentLength = response.headers.get(\"content-length\");\n const total = contentLength ? parseInt(contentLength, 10) : 0;\n\n // Create a readable stream to track progress\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error(\"Failed to create download stream\");\n }\n\n const chunks: BlobPart[] = [];\n let receivedLength = 0;\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) break;\n\n chunks.push(value);\n receivedLength += value.length;\n\n if (total > 0) {\n const progress = (receivedLength / total) * 100;\n setDownloadProgress(Math.round(progress));\n }\n }\n\n // Combine chunks into a single blob\n const blob = new Blob(chunks, {\n type: response.headers.get(\"content-type\") || \"video/mp4\",\n });\n\n // Create download link\n const url = URL.createObjectURL(blob);\n const link = document.createElement(\"a\");\n link.href = url;\n\n // Generate filename if not provided\n const defaultFilename = filename || `video-${Date.now()}.mp4`;\n link.download = defaultFilename;\n\n // Trigger download\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n\n // Clean up\n URL.revokeObjectURL(url);\n\n setDownloadProgress(100);\n setIsDownloading(false);\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Download failed\");\n setIsDownloading(false);\n setDownloadProgress(0);\n }\n },\n [videoRef]\n );\n\n // Alternative simple download method for direct video URLs\n const downloadDirect = useCallback(\n (filename?: string) => {\n if (!videoRef?.current) {\n setError(\"Video element not found\");\n return;\n }\n\n const video = videoRef.current;\n const videoSrc = video.src || video.currentSrc;\n\n if (!videoSrc) {\n setError(\"No video source found\");\n return;\n }\n\n try {\n setIsDownloading(true);\n setError(null);\n setDownloadProgress(0);\n\n const link = document.createElement(\"a\");\n link.href = videoSrc;\n link.download = filename || `video-${Date.now()}.mp4`;\n link.target = \"_blank\";\n\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n\n setIsDownloading(false);\n setDownloadProgress(100);\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Download failed\");\n setIsDownloading(false);\n setDownloadProgress(0);\n }\n },\n [videoRef]\n );\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n setIsDownloading(false);\n setDownloadProgress(0);\n setError(null);\n };\n }, []);\n\n return {\n downloadVideo,\n downloadDirect,\n isDownloading,\n downloadProgress,\n error,\n resetError: () => setError(null),\n };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useRange = (videoRef: VideoRef, range: [number, number]) => {\n React.useEffect(() => {\n if (!videoRef?.current || !range) return;\n\n const video = videoRef.current;\n\n if (video) {\n const handleTimeUpdate = () => {\n if (video.currentTime >= range[1]) {\n video.currentTime = range[0];\n } else if (video.currentTime <= range[0]) {\n video.currentTime = range[0];\n }\n };\n\n video.addEventListener(\"timeupdate\", handleTimeUpdate);\n\n return () => {\n video.removeEventListener(\"timeupdate\", handleTimeUpdate);\n };\n }\n }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B,CAAC,EAErB,IAAMmB,EAAO,SAAS,cAAc,GAAG,EACvCA,EAAK,KAAOZ,EACZY,EAAK,SAAWf,GAAY,SAAS,KAAK,IAAI,CAAC,OAC/Ce,EAAK,OAAS,SAEd,SAAS,KAAK,YAAYA,CAAI,EAC9BA,EAAK,MAAM,EACX,SAAS,KAAK,YAAYA,CAAI,EAE9BrB,EAAiB,EAAK,EACtBE,EAAoB,GAAG,CACzB,OAASqB,EAAK,CACZnB,EAASmB,aAAe,MAAQA,EAAI,QAAU,iBAAiB,EAC/DvB,EAAiB,EAAK,EACtBE,EAAoB,CAAC,CACvB,CACF,EACA,CAACJ,CAAQ,CACX,EAGA,OAAAJ,EAAU,IACD,IAAM,CACXM,EAAiB,EAAK,EACtBE,EAAoB,CAAC,EACrBE,EAAS,IAAI,CACf,EACC,CAAC,CAAC,EAEE,CACL,cAAAC,EACA,eAAAmB,EACA,cAAAzB,EACA,iBAAAE,EACA,MAAAE,EACA,WAAY,IAAMC,EAAS,IAAI,CACjC,CACF,ECzJA,OAAOqB,MAAW,QAGX,IAAMC,GAAW,CAACC,EAAoBC,IAA4B,CACvEH,EAAM,UAAU,IAAM,CACpB,GAAI,EAACE,GAAA,MAAAA,EAAU,UAAW,CAACC,EAAO,OAElC,IAAMC,EAAQF,EAAS,QAEvB,GAAIE,EAAO,CACT,IAAMC,EAAmB,IAAM,EACzBD,EAAM,aAAeD,EAAM,CAAC,GAErBC,EAAM,aAAeD,EAAM,CAAC,KACrCC,EAAM,YAAcD,EAAM,CAAC,EAE/B,EAEA,OAAAC,EAAM,iBAAiB,aAAcC,CAAgB,EAE9C,IAAM,CACXD,EAAM,oBAAoB,aAAcC,CAAgB,CAC1D,CACF,CACF,EAAG,CAACF,EAAOD,GAAA,YAAAA,EAAU,OAAO,CAAC,CAC/B","names":["React","useAutoplayByForce","videoRef","enabled","setError","_a","error","retryError","React","useAutoplayOnVisible","videoRef","threshold","enabled","observer","entries","entry","_a","error","React","useFullscreen","videoRef","isFullscreen","setIsFullscreen","previousStylesRef","handleFullscreenChange","isCurrentlyFullscreen","video","toggleFullscreen","isSafari","videoContainer","React","useGetDuration","videoRef","isLoading","setIsLoading","duration","setDuration","getDuration","_a","_b","handleError","video","useEffect","useHotKeys","key","func","enabled","handleKeyDown","event","React","useMuteUnmute","videoRef","isMuted","setIsMuted","toggleMute","mute","unmute","handleVolumeChange","_a","usePictureInPicture","videoRef","video","error","videoContainer","React","usePlayPause","videoRef","isPlaying","setIsPlaying","togglePlay","play","pause","handlePlay","handlePause","_a","_b","React","useSeek","videoRef","value","seekForward","seekBackward","React","useSpeed","videoRef","speed","setSpeed","onChangeSpeed","React","useStartAt","videoRef","startAt","video","React","useCurrentTime","videoRef","interval","isPlaying","setIsPlaying","currentTime","setCurrentTime","intervalId","_a","video","handlePlay","handlePause","time","useEffect","useState","useVideoState","videoRef","isPlaying","setIsPlaying","isMuted","setIsMuted","isFullscreen","setIsFullscreen","video","handleVolumeChange","_a","handleFullscreenChange","React","useVolume","videoRef","initialVolume","volume","setVolume","onChangeVolume","React","useBuffer","videoRef","duration","isPlaying","setIsPlaying","buffered","setBuffered","intervalId","_a","_b","useEffect","useState","useCallback","useDownload","videoRef","isDownloading","setIsDownloading","downloadProgress","setDownloadProgress","error","setError","downloadVideo","filename","_a","video","videoSrc","response","contentLength","total","reader","chunks","receivedLength","done","value","progress","blob","url","link","defaultFilename","err","downloadDirect","React","useRange","videoRef","range","video","handleTimeUpdate"]}
|
package/dist/hooks/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var J=Object.create;var i=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var d=(t,e)=>{for(var n in e)i(t,n,{get:e[n],enumerable:!0})},N=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of X(e))!Z.call(t,u)&&u!==n&&i(t,u,{get:()=>e[u],enumerable:!(s=Q(e,u))||s.enumerable});return t};var m=(t,e,n)=>(n=t!=null?J(Y(t)):{},N(e||!t||!t.__esModule?i(n,"default",{value:t,enumerable:!0}):n,t)),f=t=>N(i({},"__esModule",{value:!0}),t);var Et={};d(Et,{useAutoplayByForce:()=>v,useAutoplayOnVisible:()=>R,useBuffer:()=>yt,useCurrentTime:()=>mt,useDownload:()=>gt,useFullscreen:()=>tt,useGetDuration:()=>rt,useHotKeys:()=>nt,useMuteUnmute:()=>et,usePictureInPicture:()=>ut,usePlayPause:()=>st,useRange:()=>ht,useSeek:()=>ct,useSpeed:()=>at,useStartAt:()=>lt,useVideoState:()=>pt,useVolume:()=>ot});module.exports=f(Et);var B=m(require("react"),1),v=(t,e,n)=>{B.default.useEffect(()=>{if(!(t!=null&&t.current)||!e)return;(async()=>{var u;try{await((u=t.current)==null?void 0:u.play())}catch(a){if(a instanceof Error&&a.name==="NotAllowedError"){if(n==null||n("NotAllowedError"),console.error("NotAllowedError"),t!=null&&t.current){t.current.muted=!0;try{await t.current.play()}catch(c){console.error(c)}}}else console.error(a)}})()},[e,t==null?void 0:t.current])};var O=m(require("react"),1),R=(t,e,n=!0)=>{O.default.useEffect(()=>{if(!(t!=null&&t.current)||!n)return;let s=new IntersectionObserver(u=>{u.forEach(a=>{var c;t!=null&&t.current&&(a.isIntersecting?t.current.play().catch(r=>{t.current&&(t.current.pause(),t.current.muted=!0,t.current.play(),console.error(r))}):(c=t.current)==null||c.pause())})},{threshold:e!=null?e:.5});return s.observe(t==null?void 0:t.current),()=>{s.disconnect()}},[t==null?void 0:t.current])};var F=m(require("react"),1),tt=t=>{let[e,n]=F.default.useState(!1),s=F.default.useRef(null);F.default.useEffect(()=>{let a=()=>{let c=!!document.fullscreenElement;n(c);let r=t==null?void 0:t.current;r&&(c?(s.current={objectFit:r.style.objectFit||"cover",borderRadius:r.style.borderRadius||"",width:r.style.width||"",height:r.style.height||"",maxWidth:r.style.maxWidth||"",maxHeight:r.style.maxHeight||"",margin:r.style.margin||""},r.style.objectFit="contain",r.style.borderRadius="0",r.style.width="100%",r.style.height="100%",r.style.maxWidth="none",r.style.maxHeight="none",r.style.margin="0"):s.current&&(r.style.objectFit=s.current.objectFit,r.style.borderRadius=s.current.borderRadius,r.style.width=s.current.width,r.style.height=s.current.height,r.style.maxWidth=s.current.maxWidth,r.style.maxHeight=s.current.maxHeight,r.style.margin=s.current.margin,s.current=null))};return document.addEventListener("fullscreenchange",a),()=>document.removeEventListener("fullscreenchange",a)},[t]);let u=()=>{let a=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),c=t==null?void 0:t.current;if(c&&a){if(c.webkitEnterFullscreen){c.webkitEnterFullscreen();return}else if(c.requestFullscreen){c.requestFullscreen();return}}let r=c==null?void 0:c.closest("[data-zuude-video-wrapper]");r&&(e?document.exitFullscreen():r.requestFullscreen())};return{isFullscreen:e!=null?e:!1,toggleFullscreen:u}};var I=m(require("react"),1),rt=t=>{let[e,n]=I.default.useState(!1),[s,u]=I.default.useState(null);return I.default.useEffect(()=>{if(!(t!=null&&t.current))return;n(!0);let a=()=>{var l,p;u((p=(l=t.current)==null?void 0:l.duration)!=null?p:null),n(!1)},c=()=>{n(!1)},r=t.current;if(r.duration&&!isNaN(r.duration))u(r.duration),n(!1);else return r.addEventListener("loadedmetadata",a),r.addEventListener("error",c),r.addEventListener("loadeddata",a),()=>{r.removeEventListener("loadedmetadata",a),r.removeEventListener("error",c),r.removeEventListener("loadeddata",a)}},[t]),{duration:s,isLoading:e}};var W=require("react"),nt=(t,e,n=!0)=>{let s=u=>{u.key===t&&(u.preventDefault(),e(u))};(0,W.useEffect)(()=>{if(n)return document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s)}},[t,e,n])};var E=m(require("react"),1),et=t=>{let[e,n]=E.default.useState(!1),s=E.default.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!t.current.muted)},[t==null?void 0:t.current]),u=E.default.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!0)},[t==null?void 0:t.current]),a=E.default.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!1)},[t==null?void 0:t.current]);return E.default.useEffect(()=>{if(!(t!=null&&t.current))return;n(t.current.muted);let c=()=>{t.current&&n(t.current.muted)};return t.current.addEventListener("volumechange",c),()=>{var r;(r=t.current)==null||r.removeEventListener("volumechange",c)}},[t==null?void 0:t.current]),{toggleMute:s,isMuted:e,mute:u,unmute:a}};var ut=t=>({togglePictureInPicture:async()=>{let u=t==null?void 0:t.current;if(u)try{document.pictureInPictureElement?await document.exitPictureInPicture():await u.requestPictureInPicture()}catch(a){if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))u.webkitEnterFullscreen?u.webkitEnterFullscreen():u.requestFullscreen&&u.requestFullscreen();else{let r=u.closest("[data-zuude-video-wrapper]");r&&(document.fullscreenElement?await document.exitFullscreen():await r.requestFullscreen())}}},requestPictureInPicture:async()=>{let u=t==null?void 0:t.current;u&&await u.requestPictureInPicture()},exitPictureInPicture:async()=>{t!=null&&t.current&&await document.exitPictureInPicture()}});var b=m(require("react"),1),st=t=>{let[e,n]=b.default.useState(!1),s=b.default.useCallback(()=>{t!=null&&t.current&&(t.current.paused?t.current.play():t.current.pause())},[t==null?void 0:t.current]),u=b.default.useCallback(()=>{t!=null&&t.current&&t.current.play()},[t==null?void 0:t.current]),a=b.default.useCallback(()=>{t!=null&&t.current&&t.current.pause()},[t==null?void 0:t.current]);return b.default.useEffect(()=>{if(!(t!=null&&t.current))return;let c=()=>{n(!0)},r=()=>{n(!1)};if(n(!(t!=null&&t.current.paused)),t!=null&&t.current)return t.current.addEventListener("play",c),t.current.addEventListener("pause",r),()=>{var l,p;(l=t.current)==null||l.removeEventListener("play",c),(p=t.current)==null||p.removeEventListener("pause",r)}},[t==null?void 0:t.current]),{togglePlay:s,isPlaying:e,play:u,pause:a}};var C=m(require("react"),1),ct=(t,e=10)=>{let n=C.default.useCallback(()=>{t!=null&&t.current&&(t.current.currentTime+=e)},[t==null?void 0:t.current]),s=C.default.useCallback(()=>{t!=null&&t.current&&(t.current.currentTime-=e)},[t==null?void 0:t.current]);return{seekForward:n,seekBackward:s}};var k=m(require("react"),1),at=t=>{let[e,n]=k.default.useState(1),s=u=>{n(u)};return k.default.useEffect(()=>{t!=null&&t.current&&n(t.current.playbackRate)},[t==null?void 0:t.current]),k.default.useEffect(()=>{t!=null&&t.current&&(t.current.playbackRate=e)},[e,t==null?void 0:t.current]),{speed:e,onChangeSpeed:s}};var A=m(require("react"),1),lt=(t,e)=>{A.default.useEffect(()=>{if(!(t!=null&&t.current)||!e)return;let n=t==null?void 0:t.current;n&&e&&(n.currentTime=e)},[e,t==null?void 0:t.current])};var V=m(require("react"),1),mt=(t,e=10)=>{let[n,s]=V.default.useState(!1),[u,a]=V.default.useState(0);return V.default.useEffect(()=>{if(t!=null&&t.current&&n){let r=setInterval(()=>{var l;a(((l=t.current)==null?void 0:l.currentTime)||0)},e);return()=>clearInterval(r)}},[t==null?void 0:t.current,n]),V.default.useEffect(()=>{if(!(t!=null&&t.current))return;let r=t.current,l=()=>s(!0),p=()=>s(!1);return r.addEventListener("play",l),r.addEventListener("pause",p),()=>{r.removeEventListener("play",l),r.removeEventListener("pause",p)}},[t==null?void 0:t.current]),{currentTime:u,onTimeUpdate:r=>{t!=null&&t.current&&(a(r),t.current.currentTime=r)}}};var h=require("react"),pt=t=>{let[e,n]=(0,h.useState)(!1),[s,u]=(0,h.useState)(!1),[a,c]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{let r=t.current;if(r)return r.addEventListener("play",()=>n(!0)),r.addEventListener("pause",()=>n(!1)),()=>{r.removeEventListener("play",()=>n(!0)),r.removeEventListener("pause",()=>n(!1))}},[t]),(0,h.useEffect)(()=>{if(!(t!=null&&t.current))return;u(t.current.muted);let r=()=>{t.current&&u(t.current.muted)};return t.current.addEventListener("volumechange",r),()=>{var l;(l=t.current)==null||l.removeEventListener("volumechange",r)}},[t]),(0,h.useEffect)(()=>{if(!(t!=null&&t.current))return;let r=()=>{c(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",r),()=>document.removeEventListener("fullscreenchange",r)},[t]),{isPlaying:e,isMuted:s,isFullscreen:a}};var S=m(require("react"),1),ot=(t,e=100)=>{let[n,s]=S.default.useState(e),u=a=>{s(a)};return S.default.useEffect(()=>{t!=null&&t.current&&s(t.current.volume*100)},[t==null?void 0:t.current]),S.default.useEffect(()=>{t!=null&&t.current&&(t.current.volume=n/100)},[n,t==null?void 0:t.current]),{volume:n,onChangeVolume:u}};var P=m(require("react"),1),yt=(t,e)=>{let[n,s]=P.default.useState(!1),[u,a]=P.default.useState(0);return P.default.useEffect(()=>{if(t!=null&&t.current&&n){let c=setInterval(()=>{var r;(r=t.current)!=null&&r.buffered.length&&a(t.current.buffered.end(t.current.buffered.length-1))},10);return()=>clearInterval(c)}},[t==null?void 0:t.current,n]),P.default.useEffect(()=>{if(t!=null&&t.current)return t.current.addEventListener("play",()=>s(!0)),t.current.addEventListener("pause",()=>s(!1)),()=>{var c,r;(c=t.current)==null||c.removeEventListener("play",()=>s(!0)),(r=t.current)==null||r.removeEventListener("pause",()=>s(!1))}},[]),{buffered:u,bufferedPercentage:u/(e||0)*100||0}};var y=require("react"),gt=t=>{let[e,n]=(0,y.useState)(!1),[s,u]=(0,y.useState)(0),[a,c]=(0,y.useState)(null),r=(0,y.useCallback)(async p=>{var o;if(!(t!=null&&t.current)){c("Video element not found");return}let x=t.current,w=x.src||x.currentSrc;if(!w){c("No video source found");return}try{n(!0),c(null),u(0);let g=await fetch(w);if(!g.ok)throw new Error(`Failed to fetch video: ${g.statusText}`);let T=g.headers.get("content-length"),D=T?parseInt(T,10):0,j=(o=g.body)==null?void 0:o.getReader();if(!j)throw new Error("Failed to create download stream");let q=[],H=0;for(;;){let{done:G,value:U}=await j.read();if(G)break;if(q.push(U),H+=U.length,D>0){let _=H/D*100;u(Math.round(_))}}let $=new Blob(q,{type:g.headers.get("content-type")||"video/mp4"}),M=URL.createObjectURL($),L=document.createElement("a");L.href=M;let z=p||`video-${Date.now()}.mp4`;L.download=z,document.body.appendChild(L),L.click(),document.body.removeChild(L),URL.revokeObjectURL(M),u(100),n(!1)}catch(g){c(g instanceof Error?g.message:"Download failed"),n(!1),u(0)}},[t]),l=(0,y.useCallback)(p=>{if(!(t!=null&&t.current)){c("Video element not found");return}let x=t.current,w=x.src||x.currentSrc;if(!w){c("No video source found");return}try{n(!0),c(null),u(0);let o=document.createElement("a");o.href=w,o.download=p||`video-${Date.now()}.mp4`,o.target="_blank",document.body.appendChild(o),o.click(),document.body.removeChild(o),n(!1),u(100)}catch(o){c(o instanceof Error?o.message:"Download failed"),n(!1),u(0)}},[t]);return(0,y.useEffect)(()=>()=>{n(!1),u(0),c(null)},[]),{downloadVideo:r,downloadDirect:l,isDownloading:e,downloadProgress:s,error:a,resetError:()=>c(null)}};var K=m(require("react"),1),ht=(t,e)=>{K.default.useEffect(()=>{if(!(t!=null&&t.current)||!e)return;let n=t.current;if(n){let s=()=>{(n.currentTime>=e[1]||n.currentTime<=e[0])&&(n.currentTime=e[0])};return n.addEventListener("timeupdate",s),()=>{n.removeEventListener("timeupdate",s)}}},[e,t==null?void 0:t.current])};0&&(module.exports={useAutoplayByForce,useAutoplayOnVisible,useBuffer,useCurrentTime,useDownload,useFullscreen,useGetDuration,useHotKeys,useMuteUnmute,usePictureInPicture,usePlayPause,useRange,useSeek,useSpeed,useStartAt,useVideoState,useVolume});
|
|
1
|
+
"use strict";var J=Object.create;var F=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var d=(t,e)=>{for(var n in e)F(t,n,{get:e[n],enumerable:!0})},N=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of X(e))!Z.call(t,r)&&r!==n&&F(t,r,{get:()=>e[r],enumerable:!(s=Q(e,r))||s.enumerable});return t};var p=(t,e,n)=>(n=t!=null?J(Y(t)):{},N(e||!t||!t.__esModule?F(n,"default",{value:t,enumerable:!0}):n,t)),f=t=>N(F({},"__esModule",{value:!0}),t);var ht={};d(ht,{useAutoplayByForce:()=>v,useAutoplayOnVisible:()=>R,useBuffer:()=>yt,useCurrentTime:()=>mt,useDownload:()=>Et,useFullscreen:()=>tt,useGetDuration:()=>rt,useHotKeys:()=>nt,useMuteUnmute:()=>et,usePictureInPicture:()=>ut,usePlayPause:()=>ct,useRange:()=>gt,useSeek:()=>st,useSpeed:()=>at,useStartAt:()=>lt,useVideoState:()=>pt,useVolume:()=>ot});module.exports=f(ht);var z=p(require("react"),1),v=(t,e,n)=>{z.default.useEffect(()=>{if(!(t!=null&&t.current)||!e)return;(async()=>{var r;try{await((r=t.current)==null?void 0:r.play())}catch(c){if(c instanceof Error&&c.name==="NotAllowedError"){if(n==null||n("NotAllowedError"),console.error("NotAllowedError"),t!=null&&t.current){t.current.muted=!0;try{await t.current.play()}catch(a){console.error(a)}}}else console.error(c)}})()},[e,t==null?void 0:t.current])};var B=p(require("react"),1),R=(t,e,n=!0)=>{B.default.useEffect(()=>{if(!(t!=null&&t.current)||!n)return;let s=new IntersectionObserver(r=>{r.forEach(c=>{var a;t!=null&&t.current&&(c.isIntersecting?t.current.play().catch(u=>{t.current&&(t.current.pause(),t.current.muted=!0,t.current.play(),console.error(u))}):(a=t.current)==null||a.pause())})},{threshold:e!=null?e:.5});return s.observe(t==null?void 0:t.current),()=>{s.disconnect()}},[t==null?void 0:t.current])};var C=p(require("react"),1),tt=t=>{let[e,n]=C.default.useState(!1);C.default.useEffect(()=>{let r=t==null?void 0:t.current;if(!r)return;let c=r.closest("[data-zuude-video-wrapper]"),a=()=>document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null,u=()=>{let l=a(),m=!!l&&(l===c||l===r);n(m),r&&(console.log({isCurrentlyFullscreen:m}),m?(r.style.objectFit="contain",r.style.borderRadius="0",r.style.width="100%",r.style.height="100%",r.style.maxWidth="none",r.style.maxHeight="none",r.style.margin="0"):(r.style.objectFit="",r.style.borderRadius="",r.style.width="",r.style.height="",r.style.maxWidth="",r.style.maxHeight="",r.style.margin=""))};return u(),document.addEventListener("fullscreenchange",u),document.addEventListener("webkitfullscreenchange",u),document.addEventListener("mozfullscreenchange",u),document.addEventListener("MSFullscreenChange",u),()=>{document.removeEventListener("fullscreenchange",u),document.removeEventListener("webkitfullscreenchange",u),document.removeEventListener("mozfullscreenchange",u),document.removeEventListener("MSFullscreenChange",u)}},[t]);let s=()=>{let r=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),c=t==null?void 0:t.current;if(c&&r){if(c.webkitEnterFullscreen){c.webkitEnterFullscreen();return}else if(c.requestFullscreen){c.requestFullscreen();return}}let a=c==null?void 0:c.closest("[data-zuude-video-wrapper]");a&&(e?document.exitFullscreen():(console.log({objectFit:c==null?void 0:c.style.objectFit}),console.log({objectFit:c==null?void 0:c.style}),a.requestFullscreen()))};return{isFullscreen:e!=null?e:!1,toggleFullscreen:s}};var k=p(require("react"),1),rt=t=>{let[e,n]=k.default.useState(!1),[s,r]=k.default.useState(null);return k.default.useEffect(()=>{if(!(t!=null&&t.current))return;n(!0);let c=()=>{var l,m;r((m=(l=t.current)==null?void 0:l.duration)!=null?m:null),n(!1)},a=()=>{n(!1)},u=t.current;if(u.duration&&!isNaN(u.duration))r(u.duration),n(!1);else return u.addEventListener("loadedmetadata",c),u.addEventListener("error",a),u.addEventListener("loadeddata",c),()=>{u.removeEventListener("loadedmetadata",c),u.removeEventListener("error",a),u.removeEventListener("loadeddata",c)}},[t]),{duration:s,isLoading:e}};var O=require("react"),nt=(t,e,n=!0)=>{let s=r=>{r.key===t&&(r.preventDefault(),e(r))};(0,O.useEffect)(()=>{if(n)return document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s)}},[t,e,n])};var h=p(require("react"),1),et=t=>{let[e,n]=h.default.useState(!1),s=h.default.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!t.current.muted)},[t==null?void 0:t.current]),r=h.default.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!0)},[t==null?void 0:t.current]),c=h.default.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!1)},[t==null?void 0:t.current]);return h.default.useEffect(()=>{if(!(t!=null&&t.current))return;n(t.current.muted);let a=()=>{t.current&&n(t.current.muted)};return t.current.addEventListener("volumechange",a),()=>{var u;(u=t.current)==null||u.removeEventListener("volumechange",a)}},[t==null?void 0:t.current]),{toggleMute:s,isMuted:e,mute:r,unmute:c}};var ut=t=>({togglePictureInPicture:async()=>{let r=t==null?void 0:t.current;if(r)try{document.pictureInPictureElement?await document.exitPictureInPicture():await r.requestPictureInPicture()}catch(c){if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))r.webkitEnterFullscreen?r.webkitEnterFullscreen():r.requestFullscreen&&r.requestFullscreen();else{let u=r.closest("[data-zuude-video-wrapper]");u&&(document.fullscreenElement?await document.exitFullscreen():await u.requestFullscreen())}}},requestPictureInPicture:async()=>{let r=t==null?void 0:t.current;r&&await r.requestPictureInPicture()},exitPictureInPicture:async()=>{t!=null&&t.current&&await document.exitPictureInPicture()}});var b=p(require("react"),1),ct=t=>{let[e,n]=b.default.useState(!1),s=b.default.useCallback(()=>{t!=null&&t.current&&(t.current.paused?t.current.play():t.current.pause())},[t==null?void 0:t.current]),r=b.default.useCallback(()=>{t!=null&&t.current&&t.current.play()},[t==null?void 0:t.current]),c=b.default.useCallback(()=>{t!=null&&t.current&&t.current.pause()},[t==null?void 0:t.current]);return b.default.useEffect(()=>{if(!(t!=null&&t.current))return;let a=()=>{n(!0)},u=()=>{n(!1)};if(n(!(t!=null&&t.current.paused)),t!=null&&t.current)return t.current.addEventListener("play",a),t.current.addEventListener("pause",u),()=>{var l,m;(l=t.current)==null||l.removeEventListener("play",a),(m=t.current)==null||m.removeEventListener("pause",u)}},[t==null?void 0:t.current]),{togglePlay:s,isPlaying:e,play:r,pause:c}};var T=p(require("react"),1),st=(t,e=10)=>{let n=T.default.useCallback(()=>{t!=null&&t.current&&(t.current.currentTime+=e)},[t==null?void 0:t.current]),s=T.default.useCallback(()=>{t!=null&&t.current&&(t.current.currentTime-=e)},[t==null?void 0:t.current]);return{seekForward:n,seekBackward:s}};var I=p(require("react"),1),at=t=>{let[e,n]=I.default.useState(1),s=r=>{n(r)};return I.default.useEffect(()=>{t!=null&&t.current&&n(t.current.playbackRate)},[t==null?void 0:t.current]),I.default.useEffect(()=>{t!=null&&t.current&&(t.current.playbackRate=e)},[e,t==null?void 0:t.current]),{speed:e,onChangeSpeed:s}};var A=p(require("react"),1),lt=(t,e)=>{A.default.useEffect(()=>{if(!(t!=null&&t.current)||!e)return;let n=t==null?void 0:t.current;n&&e&&(n.currentTime=e)},[e,t==null?void 0:t.current])};var V=p(require("react"),1),mt=(t,e=10)=>{let[n,s]=V.default.useState(!1),[r,c]=V.default.useState(0);return V.default.useEffect(()=>{if(t!=null&&t.current&&n){let u=setInterval(()=>{var l;c(((l=t.current)==null?void 0:l.currentTime)||0)},e);return()=>clearInterval(u)}},[t==null?void 0:t.current,n]),V.default.useEffect(()=>{if(!(t!=null&&t.current))return;let u=t.current,l=()=>s(!0),m=()=>s(!1);return u.addEventListener("play",l),u.addEventListener("pause",m),()=>{u.removeEventListener("play",l),u.removeEventListener("pause",m)}},[t==null?void 0:t.current]),{currentTime:r,onTimeUpdate:u=>{t!=null&&t.current&&(c(u),t.current.currentTime=u)}}};var g=require("react"),pt=t=>{let[e,n]=(0,g.useState)(!1),[s,r]=(0,g.useState)(!1),[c,a]=(0,g.useState)(!1);return(0,g.useEffect)(()=>{let u=t.current;if(u)return u.addEventListener("play",()=>n(!0)),u.addEventListener("pause",()=>n(!1)),()=>{u.removeEventListener("play",()=>n(!0)),u.removeEventListener("pause",()=>n(!1))}},[t]),(0,g.useEffect)(()=>{if(!(t!=null&&t.current))return;r(t.current.muted);let u=()=>{t.current&&r(t.current.muted)};return t.current.addEventListener("volumechange",u),()=>{var l;(l=t.current)==null||l.removeEventListener("volumechange",u)}},[t]),(0,g.useEffect)(()=>{if(!(t!=null&&t.current))return;let u=()=>{a(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",u),()=>document.removeEventListener("fullscreenchange",u)},[t]),{isPlaying:e,isMuted:s,isFullscreen:c}};var S=p(require("react"),1),ot=(t,e=100)=>{let[n,s]=S.default.useState(e),r=c=>{s(c)};return S.default.useEffect(()=>{t!=null&&t.current&&s(t.current.volume*100)},[t==null?void 0:t.current]),S.default.useEffect(()=>{t!=null&&t.current&&(t.current.volume=n/100)},[n,t==null?void 0:t.current]),{volume:n,onChangeVolume:r}};var P=p(require("react"),1),yt=(t,e)=>{let[n,s]=P.default.useState(!1),[r,c]=P.default.useState(0);return P.default.useEffect(()=>{if(t!=null&&t.current&&n){let a=setInterval(()=>{var u;(u=t.current)!=null&&u.buffered.length&&c(t.current.buffered.end(t.current.buffered.length-1))},10);return()=>clearInterval(a)}},[t==null?void 0:t.current,n]),P.default.useEffect(()=>{if(t!=null&&t.current)return t.current.addEventListener("play",()=>s(!0)),t.current.addEventListener("pause",()=>s(!1)),()=>{var a,u;(a=t.current)==null||a.removeEventListener("play",()=>s(!0)),(u=t.current)==null||u.removeEventListener("pause",()=>s(!1))}},[]),{buffered:r,bufferedPercentage:r/(e||0)*100||0}};var y=require("react"),Et=t=>{let[e,n]=(0,y.useState)(!1),[s,r]=(0,y.useState)(0),[c,a]=(0,y.useState)(null),u=(0,y.useCallback)(async m=>{var o;if(!(t!=null&&t.current)){a("Video element not found");return}let L=t.current,w=L.src||L.currentSrc;if(!w){a("No video source found");return}try{n(!0),a(null),r(0);let E=await fetch(w);if(!E.ok)throw new Error(`Failed to fetch video: ${E.statusText}`);let i=E.headers.get("content-length"),D=i?parseInt(i,10):0,M=(o=E.body)==null?void 0:o.getReader();if(!M)throw new Error("Failed to create download stream");let j=[],q=0;for(;;){let{done:G,value:H}=await M.read();if(G)break;if(j.push(H),q+=H.length,D>0){let _=q/D*100;r(Math.round(_))}}let $=new Blob(j,{type:E.headers.get("content-type")||"video/mp4"}),U=URL.createObjectURL($),x=document.createElement("a");x.href=U;let W=m||`video-${Date.now()}.mp4`;x.download=W,document.body.appendChild(x),x.click(),document.body.removeChild(x),URL.revokeObjectURL(U),r(100),n(!1)}catch(E){a(E instanceof Error?E.message:"Download failed"),n(!1),r(0)}},[t]),l=(0,y.useCallback)(m=>{if(!(t!=null&&t.current)){a("Video element not found");return}let L=t.current,w=L.src||L.currentSrc;if(!w){a("No video source found");return}try{n(!0),a(null),r(0);let o=document.createElement("a");o.href=w,o.download=m||`video-${Date.now()}.mp4`,o.target="_blank",document.body.appendChild(o),o.click(),document.body.removeChild(o),n(!1),r(100)}catch(o){a(o instanceof Error?o.message:"Download failed"),n(!1),r(0)}},[t]);return(0,y.useEffect)(()=>()=>{n(!1),r(0),a(null)},[]),{downloadVideo:u,downloadDirect:l,isDownloading:e,downloadProgress:s,error:c,resetError:()=>a(null)}};var K=p(require("react"),1),gt=(t,e)=>{K.default.useEffect(()=>{if(!(t!=null&&t.current)||!e)return;let n=t.current;if(n){let s=()=>{(n.currentTime>=e[1]||n.currentTime<=e[0])&&(n.currentTime=e[0])};return n.addEventListener("timeupdate",s),()=>{n.removeEventListener("timeupdate",s)}}},[e,t==null?void 0:t.current])};0&&(module.exports={useAutoplayByForce,useAutoplayOnVisible,useBuffer,useCurrentTime,useDownload,useFullscreen,useGetDuration,useHotKeys,useMuteUnmute,usePictureInPicture,usePlayPause,useRange,useSeek,useSpeed,useStartAt,useVideoState,useVolume});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|