{"version":3,"file":"VisibleVideoPlayer.Dgo99cOU.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/bTSNNdZ8FMtXVBtBvKTJ/g5fn2cIGG1vSTV8yzj6h/VisibleVideoPlayer.js"],"sourcesContent":["// Video that plays when ≥40% in view, pauses and mutes when out of view\n// Starts muted for autoplay safety, user can click to enable sound while visible\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useInView}from\"framer\";/**\n * Smart Video Player\n *\n * @framerIntrinsicWidth 640\n * @framerIntrinsicHeight 360\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight auto\n */export default function VisibleVideoPlayer(props){const{sourceType=\"file\",videoFile=\"https://framerusercontent.com/assets/MLWPbW1dUQawJLhhun3dBwpgJak.mp4\",videoUrl=\"\",loop=true,controls=false,objectFit=\"cover\",backgroundColor=\"#000000\"}=props;const videoRef=useRef(null);const[userWantsSound,setUserWantsSound]=useState(false);const isInView=useInView(videoRef,{amount:.4});// Determine which video source to use\nconst videoSrc=sourceType===\"url\"?videoUrl:videoFile;// Handle play/pause and muting based on visibility\nuseEffect(()=>{const video=videoRef.current;if(!video)return;if(isInView){// In view: play and respect user's sound preference\nvideo.muted=!userWantsSound;video.play().catch(()=>{// Autoplay failed, ensure muted\nvideo.muted=true;video.play().catch(()=>{});});}else{// Out of view: pause and force mute\nvideo.pause();video.muted=true;// Reset user sound preference when out of view\nstartTransition(()=>setUserWantsSound(false));}},[isInView,userWantsSound]);const handleVideoClick=()=>{if(!isInView)return;const video=videoRef.current;if(!video)return;// Toggle sound only when in view\nstartTransition(()=>{setUserWantsSound(prev=>!prev);});};return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",minHeight:\"100%\",backgroundColor,overflow:\"hidden\",position:\"relative\",cursor:isInView?\"pointer\":\"default\"},onClick:handleVideoClick,children:[/*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:videoSrc,loop:loop,controls:controls,playsInline:true,muted:true,style:{width:\"100%\",height:\"100%\",objectFit}}),isInView&&!userWantsSound&&/*#__PURE__*/_jsxs(\"div\",{style:{position:\"absolute\",bottom:16,right:16,backgroundColor:\"rgba(0, 0, 0, 0.6)\",borderRadius:20,padding:\"8px 12px\",display:\"flex\",alignItems:\"center\",gap:6,pointerEvents:\"none\"},children:[/*#__PURE__*/_jsxs(\"svg\",{width:\"16\",height:\"16\",viewBox:\"0 0 24 24\",fill:\"none\",stroke:\"#FFFFFF\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",children:[/*#__PURE__*/_jsx(\"polygon\",{points:\"11 5 6 9 2 9 2 15 6 15 11 19 11 5\"}),/*#__PURE__*/_jsx(\"line\",{x1:\"23\",y1:\"9\",x2:\"17\",y2:\"15\"}),/*#__PURE__*/_jsx(\"line\",{x1:\"17\",y1:\"9\",x2:\"23\",y2:\"15\"})]}),/*#__PURE__*/_jsx(\"span\",{style:{color:\"#FFFFFF\",fontSize:12,fontWeight:500},children:\"Click for sound\"})]})]});}addPropertyControls(VisibleVideoPlayer,{sourceType:{type:ControlType.Enum,title:\"Source\",options:[\"file\",\"url\"],optionTitles:[\"File\",\"URL\"],defaultValue:\"file\",displaySegmentedControl:true},videoFile:{type:ControlType.File,allowedFileTypes:[\"mp4\",\"webm\",\"mov\"],hidden:({sourceType})=>sourceType===\"url\"},videoUrl:{type:ControlType.String,title:\"Video URL\",placeholder:\"https://example.com/video.mp4\",defaultValue:\"\",hidden:({sourceType})=>sourceType===\"file\"},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},controls:{type:ControlType.Boolean,title:\"Controls\",defaultValue:false,enabledTitle:\"Show\",disabledTitle:\"Hide\"},objectFit:{type:ControlType.Enum,title:\"Fit\",options:[\"contain\",\"cover\",\"fill\"],optionTitles:[\"Contain\",\"Cover\",\"Fill\"],defaultValue:\"cover\",displaySegmentedControl:true},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#000000\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"VisibleVideoPlayer\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicHeight\":\"360\",\"framerIntrinsicWidth\":\"640\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./VisibleVideoPlayer.map"],"mappings":"gPAUG,SAAwB,EAAmB,EAAM,CAAC,GAAK,CAAC,aAAW,OAAO,YAAU,uEAAuE,WAAS,GAAG,OAAK,GAAK,WAAS,GAAM,YAAU,QAAQ,kBAAgB,WAAW,EAAY,EAASA,EAAO,KAAK,CAAM,CAAC,EAAe,GAAmBC,EAAS,GAAM,CAAO,EAAS,EAAU,EAAS,CAAC,OAAO,GAAG,CAAC,CAClX,EAAS,IAAa,MAAM,EAAS,EAMc,OALzD,MAAc,CAAC,IAAM,EAAM,EAAS,QAAY,IAAgB,GAChE,EAAM,MAAM,CAAC,EAAe,EAAM,MAAM,CAAC,UAAU,CACnD,EAAM,MAAM,GAAK,EAAM,MAAM,CAAC,UAAU,GAAG,EAAG,GAC9C,EAAM,OAAO,CAAC,EAAM,MAAM,GAC1B,MAAoB,EAAkB,GAAM,CAAC,IAAI,CAAC,EAAS,EAAe,CAAC,CACE,EAAM,MAAM,CAAC,MAAM,CAAC,MAAM,OAAO,UAAU,OAAO,kBAAgB,SAAS,SAAS,SAAS,WAAW,OAAO,EAAS,UAAU,UAAU,CAAC,YADnH,CAAK,GAA4B,EAAS,SACjJ,MAAoB,CAAC,EAAkB,GAAM,CAAC,EAAK,EAAG,EAA6L,SAAS,CAAc,EAAK,QAAQ,CAAC,IAAI,EAAS,IAAI,EAAc,OAAc,WAAS,YAAY,GAAK,MAAM,GAAK,MAAM,CAAC,MAAM,OAAO,OAAO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