playron 1.0.14 → 1.0.15
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/playron.cjs.js +1 -1
- package/dist/playron.es.js +1 -1
- package/package.json +1 -1
package/dist/playron.cjs.js
CHANGED
|
@@ -177,7 +177,7 @@ Char: `+L[G])}return G+1&&(G+=1),U}if(L.charCodeAt(G+1)===M){G=L.indexOf(de,G),G
|
|
|
177
177
|
0% { transform: rotate(0deg); }
|
|
178
178
|
100% { transform: rotate(360deg); }
|
|
179
179
|
}
|
|
180
|
-
`,document.head.appendChild(n)}t.appendChild(this.loadingContainer),console.log("[AdManager] Loading spinner shown")}}hideAdLoading(){if(this.onLoadingChange){this.onLoadingChange(!1),console.log("[AdManager] External loading callback triggered (false)");return}this.loadingContainer&&(this.loadingContainer.remove(),this.loadingContainer=null,console.log("[AdManager] Loading spinner hidden"))}destroy(){this.hideAdLoading(),this.adPlayer.destroy(),this.preRollPlayed=!1,this.midRollsPlayed.clear(),this.postRollPlayed=!1,this.vmapData=null,console.log("[AdManager] Destroyed")}}const Dm={bottomOffset:
|
|
180
|
+
`,document.head.appendChild(n)}t.appendChild(this.loadingContainer),console.log("[AdManager] Loading spinner shown")}}hideAdLoading(){if(this.onLoadingChange){this.onLoadingChange(!1),console.log("[AdManager] External loading callback triggered (false)");return}this.loadingContainer&&(this.loadingContainer.remove(),this.loadingContainer=null,console.log("[AdManager] Loading spinner hidden"))}destroy(){this.hideAdLoading(),this.adPlayer.destroy(),this.preRollPlayed=!1,this.midRollsPlayed.clear(),this.postRollPlayed=!1,this.vmapData=null,console.log("[AdManager] Destroyed")}}const Dm={bottomOffset:140,fontSize:18,color:"#ffffff",background:"rgba(0,0,0,0.75)"},Pm=yt.createContext({style:Dm,setStyle:()=>{}});function W_({children:u}){const[e,t]=yt.useState(Dm),n=r=>t(i=>({...i,...r}));return fe.jsx(Pm.Provider,{value:{style:e,setStyle:n},children:u})}function Nm(){return yt.useContext(Pm)}function X_({videoElement:u}){const{style:e}=Nm(),[t,n]=yt.useState([]),r=yt.useRef(""),i=yt.useRef(0);return yt.useEffect(()=>{if(!u)return;const o=()=>{const l=u.textTracks,d=[];for(let g=0;g<l.length;g++){const f=l[g];if(f.kind!=="subtitles"&&f.kind!=="captions"||f.mode==="disabled")continue;f.mode==="showing"&&(f.mode="hidden");const h=f.activeCues;if(h)for(let y=0;y<h.length;y++){const E=h[y];E.text&&d.push(E.text)}}const c=d.join("\0");c!==r.current&&(r.current=c,n(d)),i.current=requestAnimationFrame(o)};return i.current=requestAnimationFrame(o),()=>{cancelAnimationFrame(i.current)}},[u]),t.length===0?null:fe.jsx("div",{"aria-live":"polite",style:{position:"absolute",bottom:e.bottomOffset,left:"50%",transform:"translateX(-50%)",textAlign:"center",pointerEvents:"none",zIndex:200,maxWidth:"85%",display:"flex",flexDirection:"column",alignItems:"center",gap:"2px"},children:t.map((o,l)=>fe.jsx("span",{style:{display:"inline-block",fontSize:e.fontSize,lineHeight:1.4,color:e.color,background:e.background||"transparent",padding:e.background?"2px 10px":"0",borderRadius:4,whiteSpace:"pre-wrap",wordBreak:"break-word",textShadow:e.background?"none":"0 1px 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.8)"},dangerouslySetInnerHTML:{__html:o}},l))})}const yo=yt.createContext(!0);function Mm({src:u="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",defaultControls:e=!1,autoplay:t=!1,muted:n=!1,poster:r,className:i,children:o,config:l,onAdLoading:d,onNextEpisode:c,nextEpisodeTitle:g,nextEpisodeThumbnail:f,endCardCountdown:h=5}){const y=yt.useRef(null),E=yt.useRef(null),[S,C]=yt.useState(null),K=yt.useRef(null),[J,re]=yt.useState(!1),[ye,Ie]=yt.useState(!1),we=yt.useCallback(()=>Ie(!0),[]),$=yt.useCallback(()=>Ie(!1),[]),[Z,pe]=yt.useState(!1),[be,Ce]=yt.useState({x:0,y:0,open:!1}),Qe=yt.useCallback(()=>Ce(st=>({...st,open:!1})),[]),xe=yt.useCallback(st=>{st.preventDefault();const jt=y.current?.getBoundingClientRect();if(!jt)return;const Qt=st.clientX-jt.left,Ne=st.clientY-jt.top;Ce({x:Qt,y:Ne,open:!0})},[]),Je=yt.useMemo(()=>{if(!S)return[];const st=S.getVideoElement(),jt=st?.loop??!1;return[{label:jt?"Loop: On":"Loop: Off",icon:fe.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[fe.jsx("polyline",{points:"17 1 21 5 17 9"}),fe.jsx("path",{d:"M3 11V9a4 4 0 0 1 4-4h14"}),fe.jsx("polyline",{points:"7 23 3 19 7 15"}),fe.jsx("path",{d:"M21 13v2a4 4 0 0 1-4 4H3"}),jt&&fe.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor",stroke:"none"})]}),onClick:()=>{if(st){const Qt=!st.loop;S.setLoop(Qt)}},dividerAfter:!1},{label:`Copy Speed (${st?.playbackRate??1}×)`,icon:fe.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[fe.jsx("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0 1 1 0 0 0-2 0"}),fe.jsx("path",{d:"M12 2a10 10 0 0 1 7.39 16.74M12 2A10 10 0 0 0 4.61 18.74"}),fe.jsx("path",{d:"m16.24 7.76-2.12 2.12"})]}),onClick:()=>{const Qt=st?.playbackRate??1;navigator.clipboard?.writeText(String(Qt)).catch(()=>{})},dividerAfter:!1},{label:"Copy Video URL",icon:fe.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[fe.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),fe.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),onClick:()=>{const Qt=st?.currentSrc??u??"";navigator.clipboard?.writeText(Qt).catch(()=>{})},dividerAfter:!0},{label:"Keyboard Shortcuts",icon:fe.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[fe.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),fe.jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M8 12h.01M12 12h.01M16 12h.01M7 16h10"})]}),onClick:()=>Ie(!0),dividerAfter:!1}]},[S,u]),{onTouchStart:Oe,onTouchMove:Me,onTouchEnd:Ve,gestureHint:ct}=Lm({player:S,skipSec:10}),{isActive:at}=q_({timeout:3e3,initialVisible:!0});G_({player:S,seekStep:10,enabled:!0,onShowShortcuts:we});const vt=yt.useMemo(()=>!l?.ads?.enabled||!l.ads.vastUrl&&!l.ads.vmapUrl?null:{enabled:!0,vastUrl:l.ads.vastUrl,vmapUrl:l.ads.vmapUrl,skipAfter:l.ads.skipAfter,timeout:l.ads.timeout,maxWrapperDepth:l.ads.maxWrapperDepth},[l?.ads?.enabled,l?.ads?.vastUrl,l?.ads?.vmapUrl,l?.ads?.skipAfter,l?.ads?.timeout,l?.ads?.maxWrapperDepth]);yt.useEffect(()=>{if(!E.current||!y.current)return;console.log("[Player] Initializing PlayerCore");const st=new Da(E.current);return st.container=y.current,C(st),()=>{console.log("[Player] Cleanup called - destroying PlayerCore"),K.current&&(console.log("[Player] Destroying AdManager"),K.current.destroy(),K.current=null),st.destroy(),C(null)}},[]),yt.useEffect(()=>{if(!S||!vt)return;console.log("[Player] Setting up ads");const st=Qt=>{re(Qt),d?.(Qt)},jt=new Y_(S,vt,st);return K.current=jt,jt.setup().catch(Qt=>{console.error("[Player] Failed to setup ads:",Qt)}),()=>{K.current&&(console.log("[Player] Cleaning up ads"),K.current.destroy(),K.current=null)}},[S,vt]);const nt=yt.useMemo(()=>l?.drm??null,[l?.drm]);return yt.useEffect(()=>{!S||!nt?.enabled||S.setupDrm(nt)},[S,nt]),yt.useEffect(()=>{S&&u&&(console.log("[Player] Setting source:",u),S.setSource(u).catch(st=>{console.error("[Player] setSource failed:",st)}))},[S,u]),yt.useEffect(()=>{if(!S||!c)return;const st=S.getVideoElement();if(!st)return;const jt=()=>pe(!0);return st.addEventListener("ended",jt),()=>st.removeEventListener("ended",jt)},[S,c]),fe.jsxs(W_,{children:[fe.jsxs("div",{ref:y,role:"region","aria-label":"Video Player",className:`playron-wrapper ${i||""}`,onContextMenu:xe,onTouchStart:Oe,onTouchMove:Me,onTouchEnd:Ve,style:{position:"relative",backgroundColor:"#000",overflow:"hidden",cursor:at?"default":"none"},children:[fe.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:{position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0}}),fe.jsx("video",{ref:E,className:`virtus-video-element ${i||""}`,style:{width:"100%",height:"100%",display:"block",aspectRatio:"16/9",objectFit:"cover",objectPosition:"center"},autoPlay:t,muted:n,controls:e,poster:r,crossOrigin:"anonymous",tabIndex:e?0:-1}),S?fe.jsx(Im,{playerInstance:S,children:fe.jsxs(yo.Provider,{value:at,children:[fe.jsx(X_,{videoElement:E.current}),fe.jsx(E_,{config:l,isAdLoading:J}),fe.jsx(Cm,{type:ct?.type??null,value:ct?.value??""}),fe.jsx(z_,{drmConfig:l?.drm}),fe.jsx(wm,{isOpen:ye,onClose:$}),c&&fe.jsx(km,{isVisible:Z,onNextEpisode:()=>{pe(!1),c()},onDismiss:()=>pe(!1),countdownSec:h,nextTitle:g,thumbnail:f}),fe.jsx(Rm,{x:be.x,y:be.y,isOpen:be.open,onClose:Qe,actions:Je}),o]})}):null]}),fe.jsx("style",{children:`
|
|
181
181
|
@keyframes gestureHintFade {
|
|
182
182
|
0% { opacity: 1; }
|
|
183
183
|
60% { opacity: 1; }
|
package/dist/playron.es.js
CHANGED
|
@@ -45492,7 +45492,7 @@ class q_ {
|
|
|
45492
45492
|
}
|
|
45493
45493
|
}
|
|
45494
45494
|
const Rm = {
|
|
45495
|
-
bottomOffset:
|
|
45495
|
+
bottomOffset: 140,
|
|
45496
45496
|
fontSize: 18,
|
|
45497
45497
|
color: "#ffffff",
|
|
45498
45498
|
background: "rgba(0,0,0,0.75)"
|