@zuude-ui/video 0.0.1
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/LICENSE +21 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +98 -0
- package/dist/index.d.ts +98 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +32 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ZuudeUI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";"use client";var ce=Object.create;var g=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var de=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty;var pe=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},O=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of le(t))!me.call(e,r)&&r!==n&&g(e,r,{get:()=>t[r],enumerable:!(o=ae(t,r))||o.enumerable});return e};var a=(e,t,n)=>(n=e!=null?ce(de(e)):{},O(t||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),fe=e=>O(g({},"__esModule",{value:!0}),e);var ye={};pe(ye,{Video:()=>ee,formatTime:()=>oe,useFullscreen:()=>M,useGetDuration:()=>ne,useMuteUnmute:()=>L,usePlayPause:()=>p,useStartAt:()=>x,useTimeline:()=>re,useVideo:()=>i,useVolume:()=>te});module.exports=fe(ye);function F(e,{insertAt:t}={}){if(!e||typeof document=="undefined")return;let n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",t==="top"&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}F(`.reset-styles{box-sizing:border-box;padding:0;margin:0}[data-zuude-video-wrapper]{position:relative}[data-zuude-video-wrapper] [data-zuude-video]{width:100%;height:100%;object-fit:cover}
|
|
2
|
+
`);var v=a(require("react"),1);var R=a(require("react"),1),k=require("react/jsx-runtime"),A=R.default.createContext(void 0),i=()=>{let e=R.default.useContext(A);if(!e)throw new Error("useVideo must be used within a VideoProvider");return e},N=({children:e,ref:t,duration:n,showHidingElement:o,setShowHidingElement:r})=>{let[s,u]=R.default.useState(!1);return(0,k.jsx)(A.Provider,{value:{ref:t,duration:n,isFullscreen:s,setIsFullscreen:u,showHidingElement:o,setShowHidingElement:r},children:e})};var z=a(require("react"),1),q=(e,t)=>{z.default.useEffect(()=>{if(!e.current||!t)return;(async()=>{var o;try{await((o=e.current)==null?void 0:o.play())}catch(r){if(r instanceof Error&&r.name==="NotAllowedError"){if(console.error("NotAllowedError"),e.current){e.current.muted=!0;try{await e.current.play()}catch(s){console.error(s)}}}else console.error(r)}})()},[t,e.current])};var $=a(require("react"),1),x=(e,t)=>{$.default.useEffect(()=>{if(!e.current||!t)return;let n=e.current;n&&t&&(n.currentTime=t)},[t])};var B=a(require("react"),1),D=(e,t,n)=>{B.default.useEffect(()=>{if(!n||!e.current)return;let o=new IntersectionObserver(r=>{r.forEach(s=>{var u;e.current&&(s.isIntersecting?e.current.play().catch(c=>{e.current&&(e.current.pause(),e.current.muted=!0,e.current.play(),console.error(c))}):(u=e.current)==null||u.pause())})},{threshold:t!=null?t:.5});return o.observe(e.current),()=>{o.disconnect()}},[n,e.current])};var b=a(require("react"),1),p=(e,t)=>{let[n,o]=b.default.useState(!1),r=b.default.useCallback(()=>{e.current&&(e.current.paused?e.current.play():e.current.pause())},[e.current]);return b.default.useEffect(()=>{if(!t||!e.current)return;let s=()=>{o(!0)},u=()=>{o(!1)};if(o(!e.current.paused),e.current)return e.current.addEventListener("play",s),e.current.addEventListener("pause",u),()=>{var c,l;(c=e.current)==null||c.removeEventListener("play",s),(l=e.current)==null||l.removeEventListener("pause",u)}},[e.current,t]),{togglePlay:r,isPlaying:n}};var U=require("react/jsx-runtime"),j=()=>{let{ref:e}=i(),{togglePlay:t}=p(e,!0);return(0,U.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"rgba(255, 0, 0, 0.2)"},onClick:t})};var C=a(require("react"),1),L=(e,t)=>{let[n,o]=C.default.useState(!1),r=C.default.useCallback(()=>{e!=null&&e.current&&(e.current.muted=!e.current.muted)},[e.current]);return C.default.useEffect(()=>{if(!t||!e.current)return;o(e.current.muted);let s=()=>{e.current&&o(e.current.muted)};return e.current.addEventListener("volumechange",s),()=>{var u;(u=e.current)==null||u.removeEventListener("volumechange",s)}},[e.current,t]),{toggleMute:r,isMuted:n}};var G=a(require("react"),1);var M=()=>{let{ref:e,isFullscreen:t,setIsFullscreen:n}=i();G.default.useEffect(()=>{let r=()=>{n==null||n(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",r),()=>document.removeEventListener("fullscreenchange",r)},[]);let o=()=>{var c;let r=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),s=e.current;if(s&&r){if(s.webkitEnterFullscreen){s.webkitEnterFullscreen();return}else if(s.requestFullscreen){s.requestFullscreen();return}}let u=(c=e.current)==null?void 0:c.closest("[data-zuude-video-wrapper]");u&&(t?document.exitFullscreen():u.requestFullscreen())};return{isFullscreen:t!=null?t:!1,toggleFullscreen:o}};var W=a(require("react"),1);var J=()=>{let{ref:e,isPictureInPicture:t,setIsPictureInPicture:n}=i();W.default.useEffect(()=>{let r=()=>{n==null||n(!!document.pictureInPictureElement)};return document.addEventListener("pictureinpicturechange",r),()=>document.removeEventListener("pictureinpicturechange",r)},[]);let o=async()=>{let r=e.current;if(r)try{document.pictureInPictureElement?await document.exitPictureInPicture():await r.requestPictureInPicture()}catch(s){if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))r.webkitEnterFullscreen?r.webkitEnterFullscreen():r.requestFullscreen&&r.requestFullscreen();else{let c=r.closest("[data-zuude-video-wrapper]");c&&(document.fullscreenElement?await document.exitFullscreen():await c.requestFullscreen())}}};return{isPictureInPicture:t!=null?t:!1,togglePictureInPicture:o}};var S=a(require("react"),1),K=(e,t)=>{let[n,o]=S.default.useState(1),r=s=>{o(s)};return S.default.useEffect(()=>{!t||!e.current||(e.current.playbackRate=n)},[n,t,e.current]),{speed:n,onChangeSpeed:r}};var Q=({ref:e,children:t})=>{let{duration:n,showHidingElement:o}=i(),{togglePlay:r,isPlaying:s}=p(e,typeof t=="function"),{speed:u,onChangeSpeed:c}=K(e,typeof t=="function"),{toggleMute:l,isMuted:m}=L(e,typeof t=="function"),{isFullscreen:E,toggleFullscreen:d}=M(),{isPictureInPicture:w,togglePictureInPicture:f}=J();return typeof t!="function"?null:t({isPlaying:s,togglePlay:r,isMuted:m,toggleMute:l,speed:u,onChangeSpeed:c,isFullscreen:E,toggleFullscreen:d,isPictureInPicture:w,togglePictureInPicture:f,duration:n,showHidingElement:o!=null?o:!1})};var X=a(require("react"),1);var Z=require("react/jsx-runtime"),Y=X.default.forwardRef(({children:e,className:t,...n})=>{let{ref:o}=i(),{isPlaying:r}=p(o,!0),{showHidingElement:s,setShowHidingElement:u}=i();return(0,Z.jsx)("div",{"data-zuude-hiding-element":!0,"data-show":!r||s,className:t,onMouseEnter:()=>{u==null||u(!0)},onMouseLeave:()=>{u==null||u(!1)},...n,children:e})});var V=require("react/jsx-runtime"),_=v.default.forwardRef(({children:e,autoPlay:t,className:n,ratio:o,config:r,controls:s,pause:u,...c},l)=>{let[m,E]=v.default.useState(null),d=l||v.default.useRef(null),[w,f]=v.default.useState(!1),y=v.default.useRef(null),ue=()=>{f(!0),y.current&&clearTimeout(y.current)},se=()=>{f(!1),y.current&&clearTimeout(y.current)},ie=()=>{f(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{f(!1)},3e3)};return v.default.useEffect(()=>{var h,H;u!==void 0&&(u?(h=d.current)==null||h.pause():(H=d.current)==null||H.play())},[u,d.current]),q(d,t==="force"&&c.muted===void 0&&!(r!=null&&r.autoplayOnVisible)),x(d,r==null?void 0:r.startAt),D(d,typeof(r==null?void 0:r.autoplayOnVisible)=="number"?r.autoplayOnVisible:void 0,r==null?void 0:r.autoplayOnVisible),(0,V.jsx)(N,{ref:d,duration:m,showHidingElement:w,setShowHidingElement:f,children:(0,V.jsxs)("div",{"data-zuude-video-wrapper":!0,style:{aspectRatio:o},className:n,children:[(0,V.jsx)("video",{"data-zuude-video":!0,ref:d,autoPlay:r!=null&&r.autoplayOnVisible?!1:t==="force"?!0:t,playsInline:!0,onMouseEnter:ue,onMouseLeave:se,onMouseMove:ie,onLoadedMetadata:h=>{E(h.target.duration)},...c}),typeof e=="function"?(0,V.jsx)(Q,{ref:d,children:e}):e]})})});_.displayName="Video";var ee=Object.assign(_,{PlayPauseOnVideo:j,HidingElement:Y});var I=a(require("react"),1);var te=()=>{let[e,t]=I.default.useState(100),{ref:n}=i(),o=r=>{t(r)};return I.default.useEffect(()=>{n.current&&(n.current.volume=e/100)},[e]),{volume:e,onChangeVolume:o}};var P=a(require("react"),1);var re=()=>{let[e,t]=P.default.useState(!1),[n,o]=P.default.useState(0),[r,s]=P.default.useState(0),{ref:u,duration:c}=i();return P.default.useEffect(()=>{if(u.current&&e){let l=setInterval(()=>{var m,E;o(((m=u.current)==null?void 0:m.currentTime)||0),(E=u.current)!=null&&E.buffered.length&&s(u.current.buffered.end(u.current.buffered.length-1))},10);return()=>clearInterval(l)}},[u.current,e]),P.default.useEffect(()=>{if(u.current)return u.current.addEventListener("play",()=>t(!0)),u.current.addEventListener("pause",()=>t(!1)),()=>{var l,m;(l=u.current)==null||l.removeEventListener("play",()=>t(!0)),(m=u.current)==null||m.removeEventListener("pause",()=>t(!1))}},[]),{currentTime:n,duration:c,buffered:r,setCurrentTime:o}};var T=a(require("react"),1);var ne=e=>{let[t,n]=T.default.useState(!1),[o,r]=T.default.useState(null),{ref:s}=i();return T.default.useEffect(()=>{if(!s.current)return;n(!0);let u=document.createElement("video");return u.src=e,u.muted=!0,u.addEventListener("loadedmetadata",()=>{r(u.duration),n(!1)}),u.addEventListener("error",()=>{n(!1)}),()=>{u.remove()}},[e]),{duration:o,isLoading:t}};function oe(e,t="mm:ss"){let n=Math.floor(e/60),o=Math.floor(e%60);return t==="h:mm:ss"?`${Math.floor(n/60)}:${n}:${o<10?"0":""}${o}`:`${n}:${o<10?"0":""}${o}`}0&&(module.exports={Video,formatTime,useFullscreen,useGetDuration,useMuteUnmute,usePlayPause,useStartAt,useTimeline,useVideo,useVolume});
|
|
3
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","#style-inject:#style-inject","../src/styles.css","../src/video.tsx","../src/context.tsx","../src/hooks/use-autoplay-by-force.tsx","../src/hooks/use-start-at.tsx","../src/hooks/use-autoplay-on-visible.tsx","../src/hooks/use-play-pause.tsx","../src/components/play-pause-on-video.tsx","../src/hooks/use-mute-unmute.tsx","../src/hooks/use-fullscreen.tsx","../src/hooks/use-picture-in-picture.tsx","../src/hooks/use-speed.tsx","../src/function-children.tsx","../src/components/hiding-element.tsx","../src/hooks/use-volume.tsx","../src/hooks/use-timeline.tsx","../src/hooks/get-duration.tsx","../src/utils.ts"],"sourcesContent":["\"use client\";\n\nimport \"./styles.css\";\n\nexport { Video } from \"./video\";\n\n// Context\nexport { useVideo } from \"./context\";\n\n// Hooks\nexport { useVolume } from \"./hooks/use-volume\";\nexport { useTimeline } from \"./hooks/use-timeline\";\nexport { useGetDuration } from \"./hooks/get-duration\";\nexport { usePlayPause } from \"./hooks/use-play-pause\";\nexport { useMuteUnmute } from \"./hooks/use-mute-unmute\";\nexport { useStartAt } from \"./hooks/use-start-at\";\nexport { useFullscreen } from \"./hooks/use-fullscreen\";\n\n// Utils\nexport { formatTime } from \"./utils\";\n","\n export default function styleInject(css, { insertAt } = {}) {\n if (!css || typeof document === 'undefined') return\n \n const head = document.head || document.getElementsByTagName('head')[0]\n const style = document.createElement('style')\n style.type = 'text/css'\n \n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild)\n } else {\n head.appendChild(style)\n }\n } else {\n head.appendChild(style)\n }\n \n if (style.styleSheet) {\n style.styleSheet.cssText = css\n } else {\n style.appendChild(document.createTextNode(css))\n }\n }\n ","import styleInject from '#style-inject';styleInject(\".reset-styles{box-sizing:border-box;padding:0;margin:0}[data-zuude-video-wrapper]{position:relative}[data-zuude-video-wrapper] [data-zuude-video]{width:100%;height:100%;object-fit:cover}\\n\")","import React from \"react\";\n\n// 📦 Types\nimport type { VideoProps } from \"./types\";\n\n// 🔍 Context\nimport { VideoProvider } from \"./context\";\n\n// 🔗 Hooks\nimport { useAutoplayByForce } from \"./hooks/use-autoplay-by-force\";\nimport { useStartAt } from \"./hooks/use-start-at\";\nimport { useAutoplayOnVisible } from \"./hooks/use-autoplay-on-visible\";\n\n// 🔧 Components\nimport { PlayPauseOnVideo } from \"./components/play-pause-on-video\";\nimport { FunctionChildren } from \"./function-children\";\nimport { HidingElement, HidingElementProps } from \"./components/hiding-element\";\n\n/**\n * Main Video component structure\n * @param {VideoProps} props - Video component props\n */\n\nconst VideoComponent = React.forwardRef<\n HTMLVideoElement,\n VideoProps & { pause?: boolean }\n>(\n (\n { children, autoPlay, className, ratio, config, controls, pause, ...props },\n ref\n ) => {\n const [duration, setDuration] = React.useState<number | null>(null);\n\n const videoRef =\n (ref as React.RefObject<HTMLVideoElement>) ||\n React.useRef<HTMLVideoElement>(null);\n\n const [showHidingElement, setShowHidingElement] = React.useState(false);\n const timeoutRef = React.useRef<ReturnType<typeof setTimeout>>(null);\n const handleMouseEnter = () => {\n setShowHidingElement(true);\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n };\n const handleMouseLeave = () => {\n setShowHidingElement(false);\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n };\n const handleMouseMove = () => {\n setShowHidingElement(true);\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n timeoutRef.current = setTimeout(() => {\n setShowHidingElement(false);\n }, 3000);\n };\n\n React.useEffect(() => {\n if (pause !== undefined) {\n if (pause) {\n videoRef.current?.pause();\n } else {\n videoRef.current?.play();\n }\n }\n }, [pause, videoRef.current]);\n\n useAutoplayByForce(\n videoRef,\n autoPlay === \"force\" &&\n props.muted === undefined &&\n !config?.autoplayOnVisible\n );\n useStartAt(videoRef, config?.startAt);\n useAutoplayOnVisible(\n videoRef,\n typeof config?.autoplayOnVisible === \"number\"\n ? config.autoplayOnVisible\n : undefined,\n config?.autoplayOnVisible\n );\n\n return (\n <VideoProvider\n ref={videoRef}\n duration={duration}\n showHidingElement={showHidingElement}\n setShowHidingElement={setShowHidingElement}\n >\n <div\n data-zuude-video-wrapper\n style={{\n aspectRatio: ratio,\n }}\n className={className}\n >\n <video\n data-zuude-video\n ref={videoRef}\n autoPlay={\n config?.autoplayOnVisible\n ? false\n : autoPlay === \"force\"\n ? true\n : autoPlay\n }\n playsInline\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onMouseMove={handleMouseMove}\n onLoadedMetadata={(e) => {\n setDuration((e.target as HTMLVideoElement).duration);\n }}\n {...props}\n />\n {typeof children === \"function\" ? (\n <FunctionChildren ref={videoRef} children={children} />\n ) : (\n children\n )}\n </div>\n </VideoProvider>\n );\n }\n);\n\nVideoComponent.displayName = \"Video\";\n\n/**\n * Using compound components pattern\n */\nexport const Video = Object.assign(VideoComponent, {\n PlayPauseOnVideo,\n HidingElement: HidingElement as React.ComponentType<HidingElementProps>,\n});\n","import React from \"react\";\nimport type { VideoContextType } from \"./types.js\";\n\nconst VideoContext = React.createContext<VideoContextType | undefined>(\n undefined\n);\n\nconst useVideo = () => {\n const context = React.useContext(VideoContext);\n if (!context) {\n throw new Error(\"useVideo must be used within a VideoProvider\");\n }\n return context;\n};\n\ninterface VideoProviderProps extends VideoContextType {\n children: React.ReactNode;\n}\n\nconst VideoProvider = ({\n children,\n ref,\n duration,\n showHidingElement,\n setShowHidingElement,\n}: VideoProviderProps) => {\n const [fullscreen, setFullscreen] = React.useState(false);\n\n return (\n <VideoContext.Provider\n value={{\n ref,\n duration,\n isFullscreen: fullscreen,\n setIsFullscreen: setFullscreen,\n showHidingElement,\n setShowHidingElement,\n }}\n >\n {children}\n </VideoContext.Provider>\n );\n};\n\nexport { useVideo, VideoProvider };\n","import React from \"react\";\nimport { VideoRef } from \"../types.js\";\n\nexport const useAutoplayByForce = (ref: VideoRef, enabled: boolean) => {\n React.useEffect(() => {\n if (!ref.current || !enabled) return;\n\n const playVideo = async () => {\n try {\n await ref.current?.play();\n } catch (error) {\n // If autoplay fails, try muting and playing again\n if (error instanceof Error && error.name === \"NotAllowedError\") {\n console.error(\"NotAllowedError\");\n if (ref.current) {\n ref.current.muted = true;\n try {\n await ref.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, ref.current]);\n};\n","import React from \"react\";\nimport type { VideoConfig, VideoRef } from \"../types\";\n\nexport const useStartAt = (ref: VideoRef, startAt?: VideoConfig[\"startAt\"]) => {\n React.useEffect(() => {\n if (!ref.current || !startAt) return;\n\n const video = ref.current;\n if (video && startAt) {\n video.currentTime = startAt;\n }\n }, [startAt]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useAutoplayOnVisible = (\n ref: VideoRef,\n threshold: number | undefined,\n enabled: boolean | number | null | undefined\n) => {\n React.useEffect(() => {\n if (!enabled || !ref.current) return;\n\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (!ref.current) return;\n\n if (entry.isIntersecting) {\n ref.current.play().catch((error) => {\n if (!ref.current) return;\n\n ref.current.pause();\n ref.current.muted = true;\n ref.current.play();\n console.error(error);\n });\n } else {\n ref.current?.pause();\n }\n });\n },\n { threshold: threshold ?? 0.5 }\n );\n\n observer.observe(ref.current);\n\n return () => {\n observer.disconnect();\n };\n }, [enabled, ref.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const usePlayPause = (ref: VideoRef, enabled: boolean) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n\n const togglePlay = React.useCallback(() => {\n if (ref.current) {\n ref.current.paused ? ref.current.play() : ref.current.pause();\n }\n }, [ref.current]);\n\n React.useEffect(() => {\n if (!enabled || !ref.current) return;\n\n const handlePlay = () => {\n setIsPlaying(true);\n };\n const handlePause = () => {\n setIsPlaying(false);\n };\n\n setIsPlaying(!ref.current.paused);\n\n if (ref.current) {\n ref.current.addEventListener(\"play\", handlePlay);\n ref.current.addEventListener(\"pause\", handlePause);\n\n return () => {\n ref.current?.removeEventListener(\"play\", handlePlay);\n ref.current?.removeEventListener(\"pause\", handlePause);\n };\n }\n }, [ref.current, enabled]);\n\n return { togglePlay, isPlaying };\n};\n","import { useVideo } from \"../context\";\nimport { usePlayPause } from \"../hooks/use-play-pause\";\n\nexport const PlayPauseOnVideo = () => {\n const { ref } = useVideo();\n\n const { togglePlay } = usePlayPause(ref, true);\n\n return (\n <div\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n backgroundColor: \"rgba(255, 0, 0, 0.2)\",\n }}\n onClick={togglePlay}\n ></div>\n );\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useMuteUnmute = (ref: VideoRef, enabled: boolean) => {\n const [isMuted, setIsMuted] = React.useState(false);\n\n const toggleMute = React.useCallback(() => {\n if (ref?.current) {\n ref.current.muted = !ref.current.muted;\n }\n }, [ref.current]);\n\n React.useEffect(() => {\n if (!enabled || !ref.current) return;\n\n // Set the initial state\n setIsMuted(ref.current.muted);\n\n const handleVolumeChange = () => {\n if (ref.current) {\n setIsMuted(ref.current.muted);\n }\n };\n\n ref.current.addEventListener(\"volumechange\", handleVolumeChange);\n\n return () => {\n ref.current?.removeEventListener(\"volumechange\", handleVolumeChange);\n };\n }, [ref.current, enabled]);\n\n return { toggleMute, isMuted };\n};\n","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const useFullscreen = () => {\n const { ref, isFullscreen, setIsFullscreen } = useVideo();\n\n React.useEffect(() => {\n const handleFullscreenChange = () => {\n setIsFullscreen?.(!!document.fullscreenElement);\n };\n\n document.addEventListener(\"fullscreenchange\", handleFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", handleFullscreenChange);\n }, []);\n\n const toggleFullscreen = () => {\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n const video = ref.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 = ref.current?.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","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const usePictureInPicture = () => {\n const { ref, isPictureInPicture, setIsPictureInPicture } = useVideo();\n\n React.useEffect(() => {\n const handlePictureInPictureChange = () => {\n setIsPictureInPicture?.(!!document.pictureInPictureElement);\n };\n\n document.addEventListener(\n \"pictureinpicturechange\",\n handlePictureInPictureChange\n );\n return () =>\n document.removeEventListener(\n \"pictureinpicturechange\",\n handlePictureInPictureChange\n );\n }, []);\n\n const togglePictureInPicture = async () => {\n const video = ref.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 return {\n isPictureInPicture: isPictureInPicture ?? false,\n togglePictureInPicture,\n };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useSpeed = (ref: VideoRef, enabled: boolean) => {\n const [speed, setSpeed] = React.useState(1);\n\n const onChangeSpeed = (speed: number) => {\n setSpeed(speed);\n };\n\n React.useEffect(() => {\n if (!enabled || !ref.current) return;\n\n ref.current.playbackRate = speed;\n }, [speed, enabled, ref.current]);\n\n return { speed, onChangeSpeed };\n};\n","import React from \"react\";\n\nimport type { VideoChildren } from \"./types\";\nimport { usePlayPause } from \"./hooks/use-play-pause\";\nimport { useMuteUnmute } from \"./hooks/use-mute-unmute\";\nimport { useVideo } from \"./context\";\nimport { useFullscreen } from \"./hooks/use-fullscreen\";\nimport { usePictureInPicture } from \"./hooks/use-picture-in-picture\";\nimport { useSpeed } from \"./hooks/use-speed\";\n\nexport const FunctionChildren = ({\n ref,\n children,\n}: {\n ref: React.RefObject<HTMLVideoElement>;\n children: VideoChildren;\n}) => {\n const { duration, showHidingElement } = useVideo();\n\n /**\n * Only use these hooks if the children is a function\n */\n const { togglePlay, isPlaying } = usePlayPause(\n ref,\n typeof children === \"function\"\n );\n const { speed, onChangeSpeed } = useSpeed(\n ref,\n typeof children === \"function\"\n );\n const { toggleMute, isMuted } = useMuteUnmute(\n ref,\n typeof children === \"function\"\n );\n const { isFullscreen, toggleFullscreen } = useFullscreen();\n const { isPictureInPicture, togglePictureInPicture } = usePictureInPicture();\n\n if (typeof children !== \"function\") return null;\n\n return children({\n isPlaying,\n togglePlay,\n isMuted,\n toggleMute,\n speed,\n onChangeSpeed,\n isFullscreen,\n toggleFullscreen,\n isPictureInPicture,\n togglePictureInPicture,\n duration,\n showHidingElement: showHidingElement ?? false,\n });\n};\n","import React from \"react\";\nimport { useVideo } from \"../context\";\nimport { usePlayPause } from \"../hooks/use-play-pause\";\n\nexport interface HidingElementProps\n extends React.ComponentPropsWithoutRef<\"div\"> {\n children: React.ReactNode;\n className?: string;\n}\n\nexport const HidingElement = React.forwardRef<\n HTMLDivElement,\n HidingElementProps\n>(({ children, className, ...props }: HidingElementProps) => {\n const { ref } = useVideo();\n const { isPlaying } = usePlayPause(ref, true);\n const { showHidingElement, setShowHidingElement } = useVideo();\n\n return (\n <div\n data-zuude-hiding-element\n data-show={!isPlaying || showHidingElement}\n className={className}\n onMouseEnter={() => {\n setShowHidingElement?.(true);\n }}\n onMouseLeave={() => {\n setShowHidingElement?.(false);\n }}\n {...props}\n >\n {children}\n </div>\n );\n});\n","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const useVolume = () => {\n const [volume, setVolume] = React.useState(100);\n const { ref } = useVideo();\n\n const onChangeVolume = (volume: number) => {\n setVolume(volume);\n };\n\n React.useEffect(() => {\n if (!ref.current) return;\n\n ref.current.volume = volume / 100;\n }, [volume]);\n\n return { volume, onChangeVolume };\n};\n","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const useTimeline = () => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n const [currentTime, setCurrentTime] = React.useState(0);\n const [buffered, setBuffered] = React.useState(0);\n\n const { ref, duration } = useVideo();\n\n React.useEffect(() => {\n if (ref.current && isPlaying) {\n const intervalId = setInterval(() => {\n setCurrentTime(ref.current?.currentTime || 0);\n\n if (ref.current?.buffered.length) {\n setBuffered(\n ref.current.buffered.end(ref.current.buffered.length - 1)\n );\n }\n }, 10);\n\n return () => clearInterval(intervalId);\n }\n }, [ref.current, isPlaying]);\n\n React.useEffect(() => {\n if (!ref.current) return;\n\n ref.current.addEventListener(\"play\", () => setIsPlaying(true));\n ref.current.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n ref.current?.removeEventListener(\"play\", () => setIsPlaying(true));\n ref.current?.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }, []);\n\n return {\n currentTime,\n duration,\n buffered,\n setCurrentTime,\n };\n};\n","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const useGetDuration = (url: string) => {\n const [isLoading, setIsLoading] = React.useState(false);\n const [duration, setDuration] = React.useState<number | null>(null);\n\n const { ref } = useVideo();\n\n React.useEffect(() => {\n if (!ref.current) return;\n\n setIsLoading(true);\n\n const video = document.createElement(\"video\");\n\n video.src = url;\n video.muted = true;\n\n video.addEventListener(\"loadedmetadata\", () => {\n setDuration(video.duration);\n setIsLoading(false);\n });\n\n video.addEventListener(\"error\", () => {\n setIsLoading(false);\n });\n\n return () => {\n video.remove();\n };\n }, [url]);\n\n return { duration, isLoading };\n};\n","function formatTime(time: number, type: \"h:mm:ss\" | \"mm:ss\" = \"mm:ss\"): string {\n const minutes = Math.floor(time / 60);\n const seconds = Math.floor(time % 60);\n if (type === \"h:mm:ss\") {\n const hours = Math.floor(minutes / 60);\n return `${hours}:${minutes}:${seconds < 10 ? \"0\" : \"\"}${seconds}`;\n }\n return `${minutes}:${seconds < 10 ? \"0\" : \"\"}${seconds}`;\n}\n\nexport { formatTime };\n"],"mappings":"mlBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,WAAAE,GAAA,eAAAC,GAAA,kBAAAC,EAAA,mBAAAC,GAAA,kBAAAC,EAAA,iBAAAC,EAAA,eAAAC,EAAA,gBAAAC,GAAA,aAAAC,EAAA,cAAAC,KAAA,eAAAC,GAAAZ,ICCyB,SAARa,EAA6BC,EAAK,CAAE,SAAAC,CAAS,EAAI,CAAC,EAAG,CAC1D,GAAI,CAACD,GAAO,OAAO,UAAa,YAAa,OAE7C,IAAME,EAAO,SAAS,MAAQ,SAAS,qBAAqB,MAAM,EAAE,CAAC,EAC/DC,EAAQ,SAAS,cAAc,OAAO,EAC5CA,EAAM,KAAO,WAETF,IAAa,OACXC,EAAK,WACPA,EAAK,aAAaC,EAAOD,EAAK,UAAU,EAK1CA,EAAK,YAAYC,CAAK,EAGpBA,EAAM,WACRA,EAAM,WAAW,QAAUH,EAE3BG,EAAM,YAAY,SAAS,eAAeH,CAAG,CAAC,CAElD,CCvB8BI,EAAY;AAAA,CAA8L,ECAlP,IAAAC,EAAkB,sBCAlB,IAAAC,EAAkB,sBA6BdC,EAAA,6BA1BEC,EAAe,EAAAC,QAAM,cACzB,MACF,EAEMC,EAAW,IAAM,CACrB,IAAMC,EAAU,EAAAF,QAAM,WAAWD,CAAY,EAC7C,GAAI,CAACG,EACH,MAAM,IAA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AAJ,MAAAK,EAAa,oBAAoB,QAAS,IAAMX,EAAa,EAAK,EACpE,CACF,EAAG,CAAC,CAAC,EAEE,CACL,YAAAE,EACA,SAAAK,EACA,SAAAH,EACA,eAAAD,CACF,CACF,EC5CA,IAAAS,EAAkB,sBAGX,IAAMC,GAAkBC,GAAgB,CAC7C,GAAM,CAACC,EAAWC,CAAY,EAAI,EAAAC,QAAM,SAAS,EAAK,EAChD,CAACC,EAAUC,CAAW,EAAI,EAAAF,QAAM,SAAwB,IAAI,EAE5D,CAAE,IAAAG,CAAI,EAAIC,EAAS,EAEzB,SAAAJ,QAAM,UAAU,IAAM,CACpB,GAAI,CAACG,EAAI,QAAS,OAElBJ,EAAa,EAAI,EAEjB,IAAMM,EAAQ,SAAS,cAAc,OAAO,EAE5C,OAAAA,EAAM,IAAMR,EACZQ,EAAM,MAAQ,GAEdA,EAAM,iBAAiB,iBAAkB,IAAM,CAC7CH,EAAYG,EAAM,QAAQ,EAC1BN,EAAa,EAAK,CACpB,CAAC,EAEDM,EAAM,iBAAiB,QAAS,IAAM,CACpCN,EAAa,EAAK,CACpB,CAAC,EAEM,IAAM,CACXM,EAAM,OAAO,CACf,CACF,EAAG,CAACR,CAAG,CAAC,EAED,CAAE,SAAAI,EAAU,UAAAH,CAAU,CAC/B,EClCA,SAASQ,GAAWC,EAAcC,EAA4B,QAAiB,CAC7E,IAAMC,EAAU,KAAK,MAAMF,EAAO,EAAE,EAC9BG,EAAU,KAAK,MAAMH,EAAO,EAAE,EACpC,OAAIC,IAAS,UAEJ,GADO,KAAK,MAAMC,EAAU,EAAE,CACtB,IAAIA,CAAO,IAAIC,EAAU,GAAK,IAAM,EAAE,GAAGA,CAAO,GAE1D,GAAGD,CAAO,IAAIC,EAAU,GAAK,IAAM,EAAE,GAAGA,CAAO,EACxD","names":["index_exports","__export","Video","formatTime","useFullscreen","useGetDuration","useMuteUnmute","usePlayPause","useStartAt","useTimeline","useVideo","useVolume","__toCommonJS","styleInject","css","insertAt","head","style","styleInject","import_react","import_react","import_jsx_runtime","VideoContext","React","useVideo","context","VideoProvider","children","ref","duration","showHidingElement","setShowHidingElement","fullscreen","setFullscreen","import_react","useAutoplayByForce","ref","enabled","React","_a","error","retryError","import_react","useStartAt","ref","startAt","React","video","import_react","useAutoplayOnVisible","ref","threshold","enabled","React","observer","entries","entry","_a","error","import_react","usePlayPause","ref","enabled","isPlaying","setIsPlaying","React","togglePlay","handlePlay","handlePause","_a","_b","import_jsx_runtime","PlayPauseOnVideo","ref","useVideo","togglePlay","usePlayPause","import_react","useMuteUnmute","ref","enabled","isMuted","setIsMuted","React","toggleMute","handleVolumeChange","_a","import_react","useFullscreen","ref","isFullscreen","setIsFullscreen","useVideo","React","handleFullscreenChange","toggleFullscreen","_a","isSafari","video","videoContainer","import_react","usePictureInPicture","ref","isPictureInPicture","setIsPictureInPicture","useVideo","React","handlePictureInPictureChange","togglePictureInPicture","video","error","videoContainer","import_react","useSpeed","ref","enabled","speed","setSpeed","React","onChangeSpeed","FunctionChildren","ref","children","duration","showHidingElement","useVideo","togglePlay","isPlaying","usePlayPause","speed","onChangeSpeed","useSpeed","toggleMute","isMuted","useMuteUnmute","isFullscreen","toggleFullscreen","useFullscreen","isPictureInPicture","togglePictureInPicture","usePictureInPicture","import_react","import_jsx_runtime","HidingElement","React","children","className","props","ref","useVideo","isPlaying","usePlayPause","showHidingElement","setShowHidingElement","import_jsx_runtime","VideoComponent","React","children","autoPlay","className","ratio","config","controls","pause","props","ref","duration","setDuration","videoRef","showHidingElement","setShowHidingElement","timeoutRef","handleMouseEnter","handleMouseLeave","handleMouseMove","_a","_b","useAutoplayByForce","useStartAt","useAutoplayOnVisible","VideoProvider","e","FunctionChildren","Video","PlayPauseOnVideo","HidingElement","import_react","useVolume","volume","setVolume","React","ref","useVideo","onChangeVolume","import_react","useTimeline","isPlaying","setIsPlaying","React","currentTime","setCurrentTime","buffered","setBuffered","ref","duration","useVideo","intervalId","_a","_b","import_react","useGetDuration","url","isLoading","setIsLoading","React","duration","setDuration","ref","useVideo","video","formatTime","time","type","minutes","seconds"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React, { ComponentPropsWithoutRef, ReactNode, RefObject } from 'react';
|
|
3
|
+
|
|
4
|
+
type VideoAutoplay = boolean | "force";
|
|
5
|
+
type VideoRef = RefObject<(Omit<HTMLVideoElement, "autoplay"> & {
|
|
6
|
+
autoplay?: VideoAutoplay;
|
|
7
|
+
}) | null>;
|
|
8
|
+
type VideoChildren = ReactNode | ((props: {
|
|
9
|
+
isPlaying: boolean;
|
|
10
|
+
togglePlay: () => void;
|
|
11
|
+
isMuted: boolean;
|
|
12
|
+
toggleMute: () => void;
|
|
13
|
+
speed: number;
|
|
14
|
+
onChangeSpeed: (speed: number) => void;
|
|
15
|
+
duration: number | null;
|
|
16
|
+
isFullscreen: boolean;
|
|
17
|
+
toggleFullscreen: () => void;
|
|
18
|
+
isPictureInPicture: boolean;
|
|
19
|
+
togglePictureInPicture: () => void;
|
|
20
|
+
showHidingElement: boolean;
|
|
21
|
+
}) => ReactNode);
|
|
22
|
+
type VideoConfig = {
|
|
23
|
+
startAt?: number;
|
|
24
|
+
range?: [number, number];
|
|
25
|
+
autoplayOnVisible?: boolean | number;
|
|
26
|
+
};
|
|
27
|
+
interface VideoProps extends Omit<ComponentPropsWithoutRef<"video">, "children" | "autoPlay" | "controls"> {
|
|
28
|
+
children?: VideoChildren;
|
|
29
|
+
autoPlay?: VideoAutoplay;
|
|
30
|
+
ratio?: string;
|
|
31
|
+
config?: VideoConfig;
|
|
32
|
+
controls?: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface VideoContextType {
|
|
35
|
+
ref: RefObject<HTMLVideoElement | null>;
|
|
36
|
+
duration: number | null;
|
|
37
|
+
isFullscreen?: boolean;
|
|
38
|
+
setIsFullscreen?: (isFullscreen: boolean) => void;
|
|
39
|
+
isPictureInPicture?: boolean;
|
|
40
|
+
setIsPictureInPicture?: (isPictureInPicture: boolean) => void;
|
|
41
|
+
showHidingElement?: boolean;
|
|
42
|
+
setShowHidingElement?: (showHidingElement: boolean) => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface HidingElementProps extends React.ComponentPropsWithoutRef<"div"> {
|
|
46
|
+
children: React.ReactNode;
|
|
47
|
+
className?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Using compound components pattern
|
|
52
|
+
*/
|
|
53
|
+
declare const Video: React.ForwardRefExoticComponent<VideoProps & {
|
|
54
|
+
pause?: boolean;
|
|
55
|
+
} & React.RefAttributes<HTMLVideoElement>> & {
|
|
56
|
+
PlayPauseOnVideo: () => react_jsx_runtime.JSX.Element;
|
|
57
|
+
HidingElement: React.ComponentType<HidingElementProps>;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
declare const useVideo: () => VideoContextType;
|
|
61
|
+
|
|
62
|
+
declare const useVolume: () => {
|
|
63
|
+
volume: number;
|
|
64
|
+
onChangeVolume: (volume: number) => void;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
declare const useTimeline: () => {
|
|
68
|
+
currentTime: number;
|
|
69
|
+
duration: number | null;
|
|
70
|
+
buffered: number;
|
|
71
|
+
setCurrentTime: React.Dispatch<React.SetStateAction<number>>;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
declare const useGetDuration: (url: string) => {
|
|
75
|
+
duration: number | null;
|
|
76
|
+
isLoading: boolean;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
declare const usePlayPause: (ref: VideoRef, enabled: boolean) => {
|
|
80
|
+
togglePlay: () => void;
|
|
81
|
+
isPlaying: boolean;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
declare const useMuteUnmute: (ref: VideoRef, enabled: boolean) => {
|
|
85
|
+
toggleMute: () => void;
|
|
86
|
+
isMuted: boolean;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
declare const useStartAt: (ref: VideoRef, startAt?: VideoConfig["startAt"]) => void;
|
|
90
|
+
|
|
91
|
+
declare const useFullscreen: () => {
|
|
92
|
+
isFullscreen: boolean;
|
|
93
|
+
toggleFullscreen: () => void;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
declare function formatTime(time: number, type?: "h:mm:ss" | "mm:ss"): string;
|
|
97
|
+
|
|
98
|
+
export { Video, formatTime, useFullscreen, useGetDuration, useMuteUnmute, usePlayPause, useStartAt, useTimeline, useVideo, useVolume };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React, { ComponentPropsWithoutRef, ReactNode, RefObject } from 'react';
|
|
3
|
+
|
|
4
|
+
type VideoAutoplay = boolean | "force";
|
|
5
|
+
type VideoRef = RefObject<(Omit<HTMLVideoElement, "autoplay"> & {
|
|
6
|
+
autoplay?: VideoAutoplay;
|
|
7
|
+
}) | null>;
|
|
8
|
+
type VideoChildren = ReactNode | ((props: {
|
|
9
|
+
isPlaying: boolean;
|
|
10
|
+
togglePlay: () => void;
|
|
11
|
+
isMuted: boolean;
|
|
12
|
+
toggleMute: () => void;
|
|
13
|
+
speed: number;
|
|
14
|
+
onChangeSpeed: (speed: number) => void;
|
|
15
|
+
duration: number | null;
|
|
16
|
+
isFullscreen: boolean;
|
|
17
|
+
toggleFullscreen: () => void;
|
|
18
|
+
isPictureInPicture: boolean;
|
|
19
|
+
togglePictureInPicture: () => void;
|
|
20
|
+
showHidingElement: boolean;
|
|
21
|
+
}) => ReactNode);
|
|
22
|
+
type VideoConfig = {
|
|
23
|
+
startAt?: number;
|
|
24
|
+
range?: [number, number];
|
|
25
|
+
autoplayOnVisible?: boolean | number;
|
|
26
|
+
};
|
|
27
|
+
interface VideoProps extends Omit<ComponentPropsWithoutRef<"video">, "children" | "autoPlay" | "controls"> {
|
|
28
|
+
children?: VideoChildren;
|
|
29
|
+
autoPlay?: VideoAutoplay;
|
|
30
|
+
ratio?: string;
|
|
31
|
+
config?: VideoConfig;
|
|
32
|
+
controls?: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface VideoContextType {
|
|
35
|
+
ref: RefObject<HTMLVideoElement | null>;
|
|
36
|
+
duration: number | null;
|
|
37
|
+
isFullscreen?: boolean;
|
|
38
|
+
setIsFullscreen?: (isFullscreen: boolean) => void;
|
|
39
|
+
isPictureInPicture?: boolean;
|
|
40
|
+
setIsPictureInPicture?: (isPictureInPicture: boolean) => void;
|
|
41
|
+
showHidingElement?: boolean;
|
|
42
|
+
setShowHidingElement?: (showHidingElement: boolean) => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface HidingElementProps extends React.ComponentPropsWithoutRef<"div"> {
|
|
46
|
+
children: React.ReactNode;
|
|
47
|
+
className?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Using compound components pattern
|
|
52
|
+
*/
|
|
53
|
+
declare const Video: React.ForwardRefExoticComponent<VideoProps & {
|
|
54
|
+
pause?: boolean;
|
|
55
|
+
} & React.RefAttributes<HTMLVideoElement>> & {
|
|
56
|
+
PlayPauseOnVideo: () => react_jsx_runtime.JSX.Element;
|
|
57
|
+
HidingElement: React.ComponentType<HidingElementProps>;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
declare const useVideo: () => VideoContextType;
|
|
61
|
+
|
|
62
|
+
declare const useVolume: () => {
|
|
63
|
+
volume: number;
|
|
64
|
+
onChangeVolume: (volume: number) => void;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
declare const useTimeline: () => {
|
|
68
|
+
currentTime: number;
|
|
69
|
+
duration: number | null;
|
|
70
|
+
buffered: number;
|
|
71
|
+
setCurrentTime: React.Dispatch<React.SetStateAction<number>>;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
declare const useGetDuration: (url: string) => {
|
|
75
|
+
duration: number | null;
|
|
76
|
+
isLoading: boolean;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
declare const usePlayPause: (ref: VideoRef, enabled: boolean) => {
|
|
80
|
+
togglePlay: () => void;
|
|
81
|
+
isPlaying: boolean;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
declare const useMuteUnmute: (ref: VideoRef, enabled: boolean) => {
|
|
85
|
+
toggleMute: () => void;
|
|
86
|
+
isMuted: boolean;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
declare const useStartAt: (ref: VideoRef, startAt?: VideoConfig["startAt"]) => void;
|
|
90
|
+
|
|
91
|
+
declare const useFullscreen: () => {
|
|
92
|
+
isFullscreen: boolean;
|
|
93
|
+
toggleFullscreen: () => void;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
declare function formatTime(time: number, type?: "h:mm:ss" | "mm:ss"): string;
|
|
97
|
+
|
|
98
|
+
export { Video, formatTime, useFullscreen, useGetDuration, useMuteUnmute, usePlayPause, useStartAt, useTimeline, useVideo, useVolume };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";function h(e,{insertAt:t}={}){if(!e||typeof document=="undefined")return;let n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",t==="top"&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}h(`.reset-styles{box-sizing:border-box;padding:0;margin:0}[data-zuude-video-wrapper]{position:relative}[data-zuude-video-wrapper] [data-zuude-video]{width:100%;height:100%;object-fit:cover}
|
|
2
|
+
`);import v from"react";import g from"react";import{jsx as G}from"react/jsx-runtime";var F=g.createContext(void 0),i=()=>{let e=g.useContext(F);if(!e)throw new Error("useVideo must be used within a VideoProvider");return e},S=({children:e,ref:t,duration:n,showHidingElement:o,setShowHidingElement:r})=>{let[s,u]=g.useState(!1);return G(F.Provider,{value:{ref:t,duration:n,isFullscreen:s,setIsFullscreen:u,showHidingElement:o,setShowHidingElement:r},children:e})};import W from"react";var I=(e,t)=>{W.useEffect(()=>{if(!e.current||!t)return;(async()=>{var o;try{await((o=e.current)==null?void 0:o.play())}catch(r){if(r instanceof Error&&r.name==="NotAllowedError"){if(console.error("NotAllowedError"),e.current){e.current.muted=!0;try{await e.current.play()}catch(s){console.error(s)}}}else console.error(r)}})()},[t,e.current])};import J from"react";var R=(e,t)=>{J.useEffect(()=>{if(!e.current||!t)return;let n=e.current;n&&t&&(n.currentTime=t)},[t])};import K from"react";var H=(e,t,n)=>{K.useEffect(()=>{if(!n||!e.current)return;let o=new IntersectionObserver(r=>{r.forEach(s=>{var u;e.current&&(s.isIntersecting?e.current.play().catch(c=>{e.current&&(e.current.pause(),e.current.muted=!0,e.current.play(),console.error(c))}):(u=e.current)==null||u.pause())})},{threshold:t!=null?t:.5});return o.observe(e.current),()=>{o.disconnect()}},[n,e.current])};import x from"react";var f=(e,t)=>{let[n,o]=x.useState(!1),r=x.useCallback(()=>{e.current&&(e.current.paused?e.current.play():e.current.pause())},[e.current]);return x.useEffect(()=>{if(!t||!e.current)return;let s=()=>{o(!0)},u=()=>{o(!1)};if(o(!e.current.paused),e.current)return e.current.addEventListener("play",s),e.current.addEventListener("pause",u),()=>{var c,a;(c=e.current)==null||c.removeEventListener("play",s),(a=e.current)==null||a.removeEventListener("pause",u)}},[e.current,t]),{togglePlay:r,isPlaying:n}};import{jsx as Q}from"react/jsx-runtime";var O=()=>{let{ref:e}=i(),{togglePlay:t}=f(e,!0);return Q("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"rgba(255, 0, 0, 0.2)"},onClick:t})};import b from"react";var C=(e,t)=>{let[n,o]=b.useState(!1),r=b.useCallback(()=>{e!=null&&e.current&&(e.current.muted=!e.current.muted)},[e.current]);return b.useEffect(()=>{if(!t||!e.current)return;o(e.current.muted);let s=()=>{e.current&&o(e.current.muted)};return e.current.addEventListener("volumechange",s),()=>{var u;(u=e.current)==null||u.removeEventListener("volumechange",s)}},[e.current,t]),{toggleMute:r,isMuted:n}};import X from"react";var L=()=>{let{ref:e,isFullscreen:t,setIsFullscreen:n}=i();X.useEffect(()=>{let r=()=>{n==null||n(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",r),()=>document.removeEventListener("fullscreenchange",r)},[]);let o=()=>{var c;let r=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),s=e.current;if(s&&r){if(s.webkitEnterFullscreen){s.webkitEnterFullscreen();return}else if(s.requestFullscreen){s.requestFullscreen();return}}let u=(c=e.current)==null?void 0:c.closest("[data-zuude-video-wrapper]");u&&(t?document.exitFullscreen():u.requestFullscreen())};return{isFullscreen:t!=null?t:!1,toggleFullscreen:o}};import Y from"react";var A=()=>{let{ref:e,isPictureInPicture:t,setIsPictureInPicture:n}=i();Y.useEffect(()=>{let r=()=>{n==null||n(!!document.pictureInPictureElement)};return document.addEventListener("pictureinpicturechange",r),()=>document.removeEventListener("pictureinpicturechange",r)},[]);let o=async()=>{let r=e.current;if(r)try{document.pictureInPictureElement?await document.exitPictureInPicture():await r.requestPictureInPicture()}catch(s){if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))r.webkitEnterFullscreen?r.webkitEnterFullscreen():r.requestFullscreen&&r.requestFullscreen();else{let c=r.closest("[data-zuude-video-wrapper]");c&&(document.fullscreenElement?await document.exitFullscreen():await c.requestFullscreen())}}};return{isPictureInPicture:t!=null?t:!1,togglePictureInPicture:o}};import N from"react";var k=(e,t)=>{let[n,o]=N.useState(1),r=s=>{o(s)};return N.useEffect(()=>{!t||!e.current||(e.current.playbackRate=n)},[n,t,e.current]),{speed:n,onChangeSpeed:r}};var z=({ref:e,children:t})=>{let{duration:n,showHidingElement:o}=i(),{togglePlay:r,isPlaying:s}=f(e,typeof t=="function"),{speed:u,onChangeSpeed:c}=k(e,typeof t=="function"),{toggleMute:a,isMuted:d}=C(e,typeof t=="function"),{isFullscreen:y,toggleFullscreen:l}=L(),{isPictureInPicture:P,togglePictureInPicture:m}=A();return typeof t!="function"?null:t({isPlaying:s,togglePlay:r,isMuted:d,toggleMute:a,speed:u,onChangeSpeed:c,isFullscreen:y,toggleFullscreen:l,isPictureInPicture:P,togglePictureInPicture:m,duration:n,showHidingElement:o!=null?o:!1})};import Z from"react";import{jsx as _}from"react/jsx-runtime";var q=Z.forwardRef(({children:e,className:t,...n})=>{let{ref:o}=i(),{isPlaying:r}=f(o,!0),{showHidingElement:s,setShowHidingElement:u}=i();return _("div",{"data-zuude-hiding-element":!0,"data-show":!r||s,className:t,onMouseEnter:()=>{u==null||u(!0)},onMouseLeave:()=>{u==null||u(!1)},...n,children:e})});import{jsx as M,jsxs as te}from"react/jsx-runtime";var $=v.forwardRef(({children:e,autoPlay:t,className:n,ratio:o,config:r,controls:s,pause:u,...c},a)=>{let[d,y]=v.useState(null),l=a||v.useRef(null),[P,m]=v.useState(!1),p=v.useRef(null),D=()=>{m(!0),p.current&&clearTimeout(p.current)},j=()=>{m(!1),p.current&&clearTimeout(p.current)},U=()=>{m(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{m(!1)},3e3)};return v.useEffect(()=>{var V,w;u!==void 0&&(u?(V=l.current)==null||V.pause():(w=l.current)==null||w.play())},[u,l.current]),I(l,t==="force"&&c.muted===void 0&&!(r!=null&&r.autoplayOnVisible)),R(l,r==null?void 0:r.startAt),H(l,typeof(r==null?void 0:r.autoplayOnVisible)=="number"?r.autoplayOnVisible:void 0,r==null?void 0:r.autoplayOnVisible),M(S,{ref:l,duration:d,showHidingElement:P,setShowHidingElement:m,children:te("div",{"data-zuude-video-wrapper":!0,style:{aspectRatio:o},className:n,children:[M("video",{"data-zuude-video":!0,ref:l,autoPlay:r!=null&&r.autoplayOnVisible?!1:t==="force"?!0:t,playsInline:!0,onMouseEnter:D,onMouseLeave:j,onMouseMove:U,onLoadedMetadata:V=>{y(V.target.duration)},...c}),typeof e=="function"?M(z,{ref:l,children:e}):e]})})});$.displayName="Video";var ee=Object.assign($,{PlayPauseOnVideo:O,HidingElement:q});import B from"react";var re=()=>{let[e,t]=B.useState(100),{ref:n}=i(),o=r=>{t(r)};return B.useEffect(()=>{n.current&&(n.current.volume=e/100)},[e]),{volume:e,onChangeVolume:o}};import E from"react";var ne=()=>{let[e,t]=E.useState(!1),[n,o]=E.useState(0),[r,s]=E.useState(0),{ref:u,duration:c}=i();return E.useEffect(()=>{if(u.current&&e){let a=setInterval(()=>{var d,y;o(((d=u.current)==null?void 0:d.currentTime)||0),(y=u.current)!=null&&y.buffered.length&&s(u.current.buffered.end(u.current.buffered.length-1))},10);return()=>clearInterval(a)}},[u.current,e]),E.useEffect(()=>{if(u.current)return u.current.addEventListener("play",()=>t(!0)),u.current.addEventListener("pause",()=>t(!1)),()=>{var a,d;(a=u.current)==null||a.removeEventListener("play",()=>t(!0)),(d=u.current)==null||d.removeEventListener("pause",()=>t(!1))}},[]),{currentTime:n,duration:c,buffered:r,setCurrentTime:o}};import T from"react";var oe=e=>{let[t,n]=T.useState(!1),[o,r]=T.useState(null),{ref:s}=i();return T.useEffect(()=>{if(!s.current)return;n(!0);let u=document.createElement("video");return u.src=e,u.muted=!0,u.addEventListener("loadedmetadata",()=>{r(u.duration),n(!1)}),u.addEventListener("error",()=>{n(!1)}),()=>{u.remove()}},[e]),{duration:o,isLoading:t}};function ue(e,t="mm:ss"){let n=Math.floor(e/60),o=Math.floor(e%60);return t==="h:mm:ss"?`${Math.floor(n/60)}:${n}:${o<10?"0":""}${o}`:`${n}:${o<10?"0":""}${o}`}export{ee as Video,ue as formatTime,L as useFullscreen,oe as useGetDuration,C as useMuteUnmute,f as usePlayPause,R as useStartAt,ne as useTimeline,i as useVideo,re as useVolume};
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["#style-inject:#style-inject","../src/styles.css","../src/video.tsx","../src/context.tsx","../src/hooks/use-autoplay-by-force.tsx","../src/hooks/use-start-at.tsx","../src/hooks/use-autoplay-on-visible.tsx","../src/hooks/use-play-pause.tsx","../src/components/play-pause-on-video.tsx","../src/hooks/use-mute-unmute.tsx","../src/hooks/use-fullscreen.tsx","../src/hooks/use-picture-in-picture.tsx","../src/hooks/use-speed.tsx","../src/function-children.tsx","../src/components/hiding-element.tsx","../src/hooks/use-volume.tsx","../src/hooks/use-timeline.tsx","../src/hooks/get-duration.tsx","../src/utils.ts"],"sourcesContent":["\n export default function styleInject(css, { insertAt } = {}) {\n if (!css || typeof document === 'undefined') return\n \n const head = document.head || document.getElementsByTagName('head')[0]\n const style = document.createElement('style')\n style.type = 'text/css'\n \n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild)\n } else {\n head.appendChild(style)\n }\n } else {\n head.appendChild(style)\n }\n \n if (style.styleSheet) {\n style.styleSheet.cssText = css\n } else {\n style.appendChild(document.createTextNode(css))\n }\n }\n ","import styleInject from '#style-inject';styleInject(\".reset-styles{box-sizing:border-box;padding:0;margin:0}[data-zuude-video-wrapper]{position:relative}[data-zuude-video-wrapper] [data-zuude-video]{width:100%;height:100%;object-fit:cover}\\n\")","import React from \"react\";\n\n// 📦 Types\nimport type { VideoProps } from \"./types\";\n\n// 🔍 Context\nimport { VideoProvider } from \"./context\";\n\n// 🔗 Hooks\nimport { useAutoplayByForce } from \"./hooks/use-autoplay-by-force\";\nimport { useStartAt } from \"./hooks/use-start-at\";\nimport { useAutoplayOnVisible } from \"./hooks/use-autoplay-on-visible\";\n\n// 🔧 Components\nimport { PlayPauseOnVideo } from \"./components/play-pause-on-video\";\nimport { FunctionChildren } from \"./function-children\";\nimport { HidingElement, HidingElementProps } from \"./components/hiding-element\";\n\n/**\n * Main Video component structure\n * @param {VideoProps} props - Video component props\n */\n\nconst VideoComponent = React.forwardRef<\n HTMLVideoElement,\n VideoProps & { pause?: boolean }\n>(\n (\n { children, autoPlay, className, ratio, config, controls, pause, ...props },\n ref\n ) => {\n const [duration, setDuration] = React.useState<number | null>(null);\n\n const videoRef =\n (ref as React.RefObject<HTMLVideoElement>) ||\n React.useRef<HTMLVideoElement>(null);\n\n const [showHidingElement, setShowHidingElement] = React.useState(false);\n const timeoutRef = React.useRef<ReturnType<typeof setTimeout>>(null);\n const handleMouseEnter = () => {\n setShowHidingElement(true);\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n };\n const handleMouseLeave = () => {\n setShowHidingElement(false);\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n };\n const handleMouseMove = () => {\n setShowHidingElement(true);\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n timeoutRef.current = setTimeout(() => {\n setShowHidingElement(false);\n }, 3000);\n };\n\n React.useEffect(() => {\n if (pause !== undefined) {\n if (pause) {\n videoRef.current?.pause();\n } else {\n videoRef.current?.play();\n }\n }\n }, [pause, videoRef.current]);\n\n useAutoplayByForce(\n videoRef,\n autoPlay === \"force\" &&\n props.muted === undefined &&\n !config?.autoplayOnVisible\n );\n useStartAt(videoRef, config?.startAt);\n useAutoplayOnVisible(\n videoRef,\n typeof config?.autoplayOnVisible === \"number\"\n ? config.autoplayOnVisible\n : undefined,\n config?.autoplayOnVisible\n );\n\n return (\n <VideoProvider\n ref={videoRef}\n duration={duration}\n showHidingElement={showHidingElement}\n setShowHidingElement={setShowHidingElement}\n >\n <div\n data-zuude-video-wrapper\n style={{\n aspectRatio: ratio,\n }}\n className={className}\n >\n <video\n data-zuude-video\n ref={videoRef}\n autoPlay={\n config?.autoplayOnVisible\n ? false\n : autoPlay === \"force\"\n ? true\n : autoPlay\n }\n playsInline\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onMouseMove={handleMouseMove}\n onLoadedMetadata={(e) => {\n setDuration((e.target as HTMLVideoElement).duration);\n }}\n {...props}\n />\n {typeof children === \"function\" ? (\n <FunctionChildren ref={videoRef} children={children} />\n ) : (\n children\n )}\n </div>\n </VideoProvider>\n );\n }\n);\n\nVideoComponent.displayName = \"Video\";\n\n/**\n * Using compound components pattern\n */\nexport const Video = Object.assign(VideoComponent, {\n PlayPauseOnVideo,\n HidingElement: HidingElement as React.ComponentType<HidingElementProps>,\n});\n","import React from \"react\";\nimport type { VideoContextType } from \"./types.js\";\n\nconst VideoContext = React.createContext<VideoContextType | undefined>(\n undefined\n);\n\nconst useVideo = () => {\n const context = React.useContext(VideoContext);\n if (!context) {\n throw new Error(\"useVideo must be used within a VideoProvider\");\n }\n return context;\n};\n\ninterface VideoProviderProps extends VideoContextType {\n children: React.ReactNode;\n}\n\nconst VideoProvider = ({\n children,\n ref,\n duration,\n showHidingElement,\n setShowHidingElement,\n}: VideoProviderProps) => {\n const [fullscreen, setFullscreen] = React.useState(false);\n\n return (\n <VideoContext.Provider\n value={{\n ref,\n duration,\n isFullscreen: fullscreen,\n setIsFullscreen: setFullscreen,\n showHidingElement,\n setShowHidingElement,\n }}\n >\n {children}\n </VideoContext.Provider>\n );\n};\n\nexport { useVideo, VideoProvider };\n","import React from \"react\";\nimport { VideoRef } from \"../types.js\";\n\nexport const useAutoplayByForce = (ref: VideoRef, enabled: boolean) => {\n React.useEffect(() => {\n if (!ref.current || !enabled) return;\n\n const playVideo = async () => {\n try {\n await ref.current?.play();\n } catch (error) {\n // If autoplay fails, try muting and playing again\n if (error instanceof Error && error.name === \"NotAllowedError\") {\n console.error(\"NotAllowedError\");\n if (ref.current) {\n ref.current.muted = true;\n try {\n await ref.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, ref.current]);\n};\n","import React from \"react\";\nimport type { VideoConfig, VideoRef } from \"../types\";\n\nexport const useStartAt = (ref: VideoRef, startAt?: VideoConfig[\"startAt\"]) => {\n React.useEffect(() => {\n if (!ref.current || !startAt) return;\n\n const video = ref.current;\n if (video && startAt) {\n video.currentTime = startAt;\n }\n }, [startAt]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useAutoplayOnVisible = (\n ref: VideoRef,\n threshold: number | undefined,\n enabled: boolean | number | null | undefined\n) => {\n React.useEffect(() => {\n if (!enabled || !ref.current) return;\n\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (!ref.current) return;\n\n if (entry.isIntersecting) {\n ref.current.play().catch((error) => {\n if (!ref.current) return;\n\n ref.current.pause();\n ref.current.muted = true;\n ref.current.play();\n console.error(error);\n });\n } else {\n ref.current?.pause();\n }\n });\n },\n { threshold: threshold ?? 0.5 }\n );\n\n observer.observe(ref.current);\n\n return () => {\n observer.disconnect();\n };\n }, [enabled, ref.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const usePlayPause = (ref: VideoRef, enabled: boolean) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n\n const togglePlay = React.useCallback(() => {\n if (ref.current) {\n ref.current.paused ? ref.current.play() : ref.current.pause();\n }\n }, [ref.current]);\n\n React.useEffect(() => {\n if (!enabled || !ref.current) return;\n\n const handlePlay = () => {\n setIsPlaying(true);\n };\n const handlePause = () => {\n setIsPlaying(false);\n };\n\n setIsPlaying(!ref.current.paused);\n\n if (ref.current) {\n ref.current.addEventListener(\"play\", handlePlay);\n ref.current.addEventListener(\"pause\", handlePause);\n\n return () => {\n ref.current?.removeEventListener(\"play\", handlePlay);\n ref.current?.removeEventListener(\"pause\", handlePause);\n };\n }\n }, [ref.current, enabled]);\n\n return { togglePlay, isPlaying };\n};\n","import { useVideo } from \"../context\";\nimport { usePlayPause } from \"../hooks/use-play-pause\";\n\nexport const PlayPauseOnVideo = () => {\n const { ref } = useVideo();\n\n const { togglePlay } = usePlayPause(ref, true);\n\n return (\n <div\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n backgroundColor: \"rgba(255, 0, 0, 0.2)\",\n }}\n onClick={togglePlay}\n ></div>\n );\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useMuteUnmute = (ref: VideoRef, enabled: boolean) => {\n const [isMuted, setIsMuted] = React.useState(false);\n\n const toggleMute = React.useCallback(() => {\n if (ref?.current) {\n ref.current.muted = !ref.current.muted;\n }\n }, [ref.current]);\n\n React.useEffect(() => {\n if (!enabled || !ref.current) return;\n\n // Set the initial state\n setIsMuted(ref.current.muted);\n\n const handleVolumeChange = () => {\n if (ref.current) {\n setIsMuted(ref.current.muted);\n }\n };\n\n ref.current.addEventListener(\"volumechange\", handleVolumeChange);\n\n return () => {\n ref.current?.removeEventListener(\"volumechange\", handleVolumeChange);\n };\n }, [ref.current, enabled]);\n\n return { toggleMute, isMuted };\n};\n","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const useFullscreen = () => {\n const { ref, isFullscreen, setIsFullscreen } = useVideo();\n\n React.useEffect(() => {\n const handleFullscreenChange = () => {\n setIsFullscreen?.(!!document.fullscreenElement);\n };\n\n document.addEventListener(\"fullscreenchange\", handleFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", handleFullscreenChange);\n }, []);\n\n const toggleFullscreen = () => {\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n const video = ref.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 = ref.current?.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","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const usePictureInPicture = () => {\n const { ref, isPictureInPicture, setIsPictureInPicture } = useVideo();\n\n React.useEffect(() => {\n const handlePictureInPictureChange = () => {\n setIsPictureInPicture?.(!!document.pictureInPictureElement);\n };\n\n document.addEventListener(\n \"pictureinpicturechange\",\n handlePictureInPictureChange\n );\n return () =>\n document.removeEventListener(\n \"pictureinpicturechange\",\n handlePictureInPictureChange\n );\n }, []);\n\n const togglePictureInPicture = async () => {\n const video = ref.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 return {\n isPictureInPicture: isPictureInPicture ?? false,\n togglePictureInPicture,\n };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useSpeed = (ref: VideoRef, enabled: boolean) => {\n const [speed, setSpeed] = React.useState(1);\n\n const onChangeSpeed = (speed: number) => {\n setSpeed(speed);\n };\n\n React.useEffect(() => {\n if (!enabled || !ref.current) return;\n\n ref.current.playbackRate = speed;\n }, [speed, enabled, ref.current]);\n\n return { speed, onChangeSpeed };\n};\n","import React from \"react\";\n\nimport type { VideoChildren } from \"./types\";\nimport { usePlayPause } from \"./hooks/use-play-pause\";\nimport { useMuteUnmute } from \"./hooks/use-mute-unmute\";\nimport { useVideo } from \"./context\";\nimport { useFullscreen } from \"./hooks/use-fullscreen\";\nimport { usePictureInPicture } from \"./hooks/use-picture-in-picture\";\nimport { useSpeed } from \"./hooks/use-speed\";\n\nexport const FunctionChildren = ({\n ref,\n children,\n}: {\n ref: React.RefObject<HTMLVideoElement>;\n children: VideoChildren;\n}) => {\n const { duration, showHidingElement } = useVideo();\n\n /**\n * Only use these hooks if the children is a function\n */\n const { togglePlay, isPlaying } = usePlayPause(\n ref,\n typeof children === \"function\"\n );\n const { speed, onChangeSpeed } = useSpeed(\n ref,\n typeof children === \"function\"\n );\n const { toggleMute, isMuted } = useMuteUnmute(\n ref,\n typeof children === \"function\"\n );\n const { isFullscreen, toggleFullscreen } = useFullscreen();\n const { isPictureInPicture, togglePictureInPicture } = usePictureInPicture();\n\n if (typeof children !== \"function\") return null;\n\n return children({\n isPlaying,\n togglePlay,\n isMuted,\n toggleMute,\n speed,\n onChangeSpeed,\n isFullscreen,\n toggleFullscreen,\n isPictureInPicture,\n togglePictureInPicture,\n duration,\n showHidingElement: showHidingElement ?? false,\n });\n};\n","import React from \"react\";\nimport { useVideo } from \"../context\";\nimport { usePlayPause } from \"../hooks/use-play-pause\";\n\nexport interface HidingElementProps\n extends React.ComponentPropsWithoutRef<\"div\"> {\n children: React.ReactNode;\n className?: string;\n}\n\nexport const HidingElement = React.forwardRef<\n HTMLDivElement,\n HidingElementProps\n>(({ children, className, ...props }: HidingElementProps) => {\n const { ref } = useVideo();\n const { isPlaying } = usePlayPause(ref, true);\n const { showHidingElement, setShowHidingElement } = useVideo();\n\n return (\n <div\n data-zuude-hiding-element\n data-show={!isPlaying || showHidingElement}\n className={className}\n onMouseEnter={() => {\n setShowHidingElement?.(true);\n }}\n onMouseLeave={() => {\n setShowHidingElement?.(false);\n }}\n {...props}\n >\n {children}\n </div>\n );\n});\n","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const useVolume = () => {\n const [volume, setVolume] = React.useState(100);\n const { ref } = useVideo();\n\n const onChangeVolume = (volume: number) => {\n setVolume(volume);\n };\n\n React.useEffect(() => {\n if (!ref.current) return;\n\n ref.current.volume = volume / 100;\n }, [volume]);\n\n return { volume, onChangeVolume };\n};\n","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const useTimeline = () => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n const [currentTime, setCurrentTime] = React.useState(0);\n const [buffered, setBuffered] = React.useState(0);\n\n const { ref, duration } = useVideo();\n\n React.useEffect(() => {\n if (ref.current && isPlaying) {\n const intervalId = setInterval(() => {\n setCurrentTime(ref.current?.currentTime || 0);\n\n if (ref.current?.buffered.length) {\n setBuffered(\n ref.current.buffered.end(ref.current.buffered.length - 1)\n );\n }\n }, 10);\n\n return () => clearInterval(intervalId);\n }\n }, [ref.current, isPlaying]);\n\n React.useEffect(() => {\n if (!ref.current) return;\n\n ref.current.addEventListener(\"play\", () => setIsPlaying(true));\n ref.current.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n ref.current?.removeEventListener(\"play\", () => setIsPlaying(true));\n ref.current?.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }, []);\n\n return {\n currentTime,\n duration,\n buffered,\n setCurrentTime,\n };\n};\n","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const useGetDuration = (url: string) => {\n const [isLoading, setIsLoading] = React.useState(false);\n const [duration, setDuration] = React.useState<number | null>(null);\n\n const { ref } = useVideo();\n\n React.useEffect(() => {\n if (!ref.current) return;\n\n setIsLoading(true);\n\n const video = document.createElement(\"video\");\n\n video.src = url;\n video.muted = true;\n\n video.addEventListener(\"loadedmetadata\", () => {\n setDuration(video.duration);\n setIsLoading(false);\n });\n\n video.addEventListener(\"error\", () => {\n setIsLoading(false);\n });\n\n return () => {\n video.remove();\n };\n }, [url]);\n\n return { duration, isLoading };\n};\n","function formatTime(time: number, type: \"h:mm:ss\" | \"mm:ss\" = \"mm:ss\"): string {\n const minutes = Math.floor(time / 60);\n const seconds = Math.floor(time % 60);\n if (type === \"h:mm:ss\") {\n const hours = Math.floor(minutes / 60);\n return `${hours}:${minutes}:${seconds < 10 ? \"0\" : \"\"}${seconds}`;\n }\n return `${minutes}:${seconds < 10 ? \"0\" : \"\"}${seconds}`;\n}\n\nexport { formatTime };\n"],"mappings":"aACyB,SAARA,E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AEM,IAAM,CACXM,EAAM,OAAO,CACf,CACF,EAAG,CAACR,CAAG,CAAC,EAED,CAAE,SAAAI,EAAU,UAAAH,CAAU,CAC/B,EClCA,SAASQ,GAAWC,EAAcC,EAA4B,QAAiB,CAC7E,IAAMC,EAAU,KAAK,MAAMF,EAAO,EAAE,EAC9BG,EAAU,KAAK,MAAMH,EAAO,EAAE,EACpC,OAAIC,IAAS,UAEJ,GADO,KAAK,MAAMC,EAAU,EAAE,CACtB,IAAIA,CAAO,IAAIC,EAAU,GAAK,IAAM,EAAE,GAAGA,CAAO,GAE1D,GAAGD,CAAO,IAAIC,EAAU,GAAK,IAAM,EAAE,GAAGA,CAAO,EACxD","names":["styleInject","css","insertAt","head","style","styleInject","React","React","jsx","VideoContext","useVideo","context","VideoProvider","children","ref","duration","showHidingElement","setShowHidingElement","fullscreen","setFullscreen","React","useAutoplayByForce","ref","enabled","_a","error","retryError","React","useStartAt","ref","startAt","video","React","useAutoplayOnVisible","ref","threshold","enabled","observer","entries","entry","_a","error","React","usePlayPause","ref","enabled","isPlaying","setIsPlaying","togglePlay","handlePlay","handlePause","_a","_b","jsx","PlayPauseOnVideo","ref","useVideo","togglePlay","usePlayPause","React","useMuteUnmute","ref","enabled","isMuted","setIsMuted","toggleMute","handleVolumeChange","_a","React","useFullscreen","ref","isFullscreen","setIsFullscreen","useVideo","React","handleFullscreenChange","toggleFullscreen","_a","isSafari","video","videoContainer","React","usePictureInPicture","ref","isPictureInPicture","setIsPictureInPicture","useVideo","React","handlePictureInPictureChange","togglePictureInPicture","video","error","videoContainer","React","useSpeed","ref","enabled","speed","setSpeed","onChangeSpeed","FunctionChildren","ref","children","duration","showHidingElement","useVideo","togglePlay","isPlaying","usePlayPause","speed","onChangeSpeed","useSpeed","toggleMute","isMuted","useMuteUnmute","isFullscreen","toggleFullscreen","useFullscreen","isPictureInPicture","togglePictureInPicture","usePictureInPicture","React","jsx","HidingElement","React","children","className","props","ref","useVideo","isPlaying","usePlayPause","showHidingElement","setShowHidingElement","jsx","jsxs","VideoComponent","React","children","autoPlay","className","ratio","config","controls","pause","props","ref","duration","setDuration","videoRef","showHidingElement","setShowHidingElement","timeoutRef","handleMouseEnter","handleMouseLeave","handleMouseMove","_a","_b","useAutoplayByForce","useStartAt","useAutoplayOnVisible","VideoProvider","e","FunctionChildren","Video","PlayPauseOnVideo","HidingElement","React","useVolume","volume","setVolume","React","ref","useVideo","onChangeVolume","React","useTimeline","isPlaying","setIsPlaying","React","currentTime","setCurrentTime","buffered","setBuffered","ref","duration","useVideo","intervalId","_a","_b","React","useGetDuration","url","isLoading","setIsLoading","React","duration","setDuration","ref","useVideo","video","formatTime","time","type","minutes","seconds"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zuude-ui/video",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.0.1",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/**"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"keywords": [],
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"description": "",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"tsup": "^8.5.0",
|
|
20
|
+
"typescript": "^5.8.3"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"react": "^19.0.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/react": "^19.0.10"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsup",
|
|
30
|
+
"lint": "tsc"
|
|
31
|
+
}
|
|
32
|
+
}
|