@devix-technologies/react-gjirafa-vp-player 1.0.10 → 1.0.11
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/react-gjirafa-vp-player.es.js +8 -5
- package/dist/react-gjirafa-vp-player.umd.js +1 -1
- package/package.json +1 -1
- package/dist/App.d.ts +0 -2
- package/dist/components/Feedback.d.ts +0 -25
- package/dist/components/VPPlayer/index.d.ts +0 -2
- package/dist/components/VPPlayer/ui/index.d.ts +0 -1
- package/dist/components/VPPlayer/ui/styled.d.ts +0 -42
- package/dist/config/index.d.ts +0 -1
- package/dist/config/vpPlayerConfig.d.ts +0 -9
- package/dist/constants/configs.d.ts +0 -22
- package/dist/constants/index.d.ts +0 -1
- package/dist/constants/storybook.d.ts +0 -11
- package/dist/constants/styles.d.ts +0 -11
- package/dist/constants/urls.d.ts +0 -18
- package/dist/constants/vpPlayer.d.ts +0 -29
- package/dist/contexts/VPPlayerContext.d.ts +0 -53
- package/dist/contexts/index.d.ts +0 -1
- package/dist/features/VPPlayer.d.ts +0 -27
- package/dist/features/stories/ads/Ads.stories.d.ts +0 -20
- package/dist/features/stories/context/Context.stories.d.ts +0 -10
- package/dist/features/stories/index.d.ts +0 -3
- package/dist/features/stories/playback/Playback.stories.d.ts +0 -33
- package/dist/fixtures/index.d.ts +0 -1
- package/dist/fixtures/playlist.d.ts +0 -11
- package/dist/hooks/index.d.ts +0 -3
- package/dist/hooks/useVPPlayerLogic.d.ts +0 -22
- package/dist/hooks/useVPPlayerScript.d.ts +0 -13
- package/dist/hooks/useVideoData.d.ts +0 -21
- package/dist/index.d.ts +0 -9
- package/dist/interfaces/config.d.ts +0 -311
- package/dist/interfaces/index.d.ts +0 -3
- package/dist/interfaces/instance.d.ts +0 -73
- package/dist/interfaces/props.d.ts +0 -54
- package/dist/main.d.ts +0 -1
- package/dist/types/api.types.d.ts +0 -50
- package/dist/types/index.d.ts +0 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/vpPlayerConfigBuilder.d.ts +0 -30
- package/dist/utils/vpPlayerUtils.d.ts +0 -8
|
@@ -1630,7 +1630,7 @@ const gr = ne.div`
|
|
|
1630
1630
|
projectId: n || "vp-player-projectId",
|
|
1631
1631
|
video: {
|
|
1632
1632
|
...s.video,
|
|
1633
|
-
// Set target video file and metadata
|
|
1633
|
+
// Set target video file and metadata
|
|
1634
1634
|
file: u == null ? void 0 : u.hlsUrl,
|
|
1635
1635
|
title: u == null ? void 0 : u.title,
|
|
1636
1636
|
// Don't set thumbnail - let VP Player manage thumbnails during scrolling
|
|
@@ -1641,10 +1641,13 @@ const gr = ne.div`
|
|
|
1641
1641
|
// Will be set by API
|
|
1642
1642
|
// Use original playlistVideoIndex - VP Player will navigate to it
|
|
1643
1643
|
playlistVideoIndex: Number(x),
|
|
1644
|
-
// Remove first video from playlist to avoid duplication (already in file)
|
|
1645
|
-
videos:
|
|
1646
|
-
|
|
1647
|
-
|
|
1644
|
+
// // Remove first video from playlist to avoid duplication (already in file)
|
|
1645
|
+
// videos: fetchedPlaylist.slice(1).map((video, index) => ({
|
|
1646
|
+
// videoId: String(index + 1), // Keep original IDs
|
|
1647
|
+
// Keep all videos in playlist (don't remove first video)
|
|
1648
|
+
videos: r.map(($, R) => ({
|
|
1649
|
+
videoId: String(R),
|
|
1650
|
+
// Use 0-based indexing
|
|
1648
1651
|
title: $.title,
|
|
1649
1652
|
file: $.hlsUrl,
|
|
1650
1653
|
thumbnailUrl: $.thumbnailUrl,
|
|
@@ -81,4 +81,4 @@ React keys must be passed directly to JSX without using spread:
|
|
|
81
81
|
@media (min-width: 768px) {
|
|
82
82
|
width: min(70vw, 960px); /* Responsive width for desktop, capped at 960px */
|
|
83
83
|
}
|
|
84
|
-
`,vr=(e,t)=>`https://vp-api.gjirafa.tech/api/v2/projects/${e}/videos?search=${t}`,wr=(e,t)=>`https://vp-api.gjirafa.tech/api/projects/${e}/playlists/${t}/videos`,xr=e=>`https://host.vpplayer.tech/player/${e}/vpplayer.js`,Ne=(e,t)=>`vp-player-${e||"default"}-${t||""}`,$e=new Map,dt=(e,t)=>{const[r,n]=k.useState(!1),[a,i]=k.useState(null);return k.useEffect(()=>{let s=null,c,d=0;const m=3;let l;try{l=t||xr(e||"latest")}catch(P){const b=P instanceof Error?P.message:String(P);i(`Failed to resolve script URL: ${b}`),n(!1);return}if($e.get(l)){n(!0),i(null);return}if(document.querySelector(`script[src="${l}"]`)){$e.set(l,!0),n(!0),i(null);return}const g=()=>{s=document.createElement("script"),s.src=l,s.async=!0,c=window.setTimeout(()=>{n(!1),i(`Loading script timed out: ${l}`)},1e4),s.onload=()=>{clearTimeout(c),$e.set(l,!0),n(!0),i(null)},s.onerror=()=>{clearTimeout(c),d++,d<m?setTimeout(g,1e3*d):(n(!1),i(`Failed to load VP Player script after ${m} attempts: ${l}`))},document.body.appendChild(s)};return g(),()=>{clearTimeout(c),s&&document.body.contains(s)&&document.body.removeChild(s)}},[e,t]),{isLoaded:r,error:a}},Pr={},Ee=new Map,kr=3e4,Ve=5,ft=({projectId:e,videoId:t,playlistId:r,videoUrl:n,apiKey:a})=>{const[i,s]=k.useState(null),[c,d]=k.useState(null),[m,l]=k.useState(!1),[p,g]=k.useState(null),P=a||(typeof Pr<"u"?"1CFC4B619E9342B6BAC4879BA8C30CF216C4BA9D3F084B11825F4AB2D5CF845E":void 0);return k.useEffect(()=>{const b=t?`video:${t}`:r?`playlist:${r}`:null;if(!e||n||!t&&!r){s(n||null),d(null),l(!1),g(null);return}if(!P){l(!1),g("No API key provided");return}if(b&&Ee.has(b)){const R=Ee.get(b);s(R.url),d(R.playlist),l(!1),g(null);return}let f=!0;const h=new AbortController,y=h.signal,A=setTimeout(async()=>{var w,C;if(!f)return;l(!0),g(null);let R=0;for(;R<Ve&&f;)try{const u=t&&!r?vr(e,t):wr(e,r),I=setTimeout(()=>h.abort(),kr),V=await fetch(u,{method:"GET",headers:{"api-key":P,Accept:"application/json","Cache-Control":"no-cache"},signal:y});if(clearTimeout(I),!V.ok)throw new Error(`Fetch failed with status ${V.status}`);const T=await V.json();if(!f)return;if(t&&!r){const L=(C=(w=T.result)==null?void 0:w.items)==null?void 0:C.find(X=>X.mediaId===t);if(!(L!=null&&L.playbackUrl))throw new Error("Invalid video data");s(L.playbackUrl),d(null),b&&Ee.set(b,{url:L.playbackUrl,playlist:null})}else{if(!Array.isArray(T.result))throw new Error("Invalid playlist format");d(T.result),s(null),b&&Ee.set(b,{url:null,playlist:T.result})}break}catch(u){if(y.aborted){f&&g("Request timed out");break}if(R++,R>=Ve){const I=u instanceof Error?u.message:String(u);f&&g(`Failed after ${Ve} attempts: ${I}`)}else await new Promise(I=>setTimeout(I,2e3))}f&&l(!1)},100);return()=>{f=!1,clearTimeout(A),h.abort()}},[P,e,t,r,n]),{fetchedPlaybackUrl:i,fetchedPlaylist:c,isLoading:m,error:p}},Er={projectId:"vp-player-projectId",video:{file:"",playlist:{state:!0,playlistVideoIndex:0,videos:[]}},config:{autoplay:!0,muted:!0,loop:!1,size:{width:"100%",height:"30vh"},controls:{settingsButton:!0,chromecastButton:!1,nextButton:!0,fullscreenButton:!0,airplayButton:!1,bigPlayButton:!1,autopausePlayButton:!0,pictureInPictureButton:!1,relatedButton:!1,volumeButton:!0,shareButton:!0}}},pt=({videoUrl:e,fetchedPlaybackUrl:t,fetchedPlaylist:r,projectId:n,config:a={},isVerticalPlayer:i})=>{var l,p,g,P,b,f,h,y,x,A,R;const s={...Er,...a},c={...s.config,...a.config};if(e)return{...s,video:{...s.video,file:e,playlist:void 0},config:c};if(t)return{...s,video:{...s.video,file:t,playlist:void 0},config:c};if(r&&r.length>0){const w=((p=(l=a==null?void 0:a.video)==null?void 0:l.playlist)==null?void 0:p.playlistVideoIndex)??((g=a==null?void 0:a.config)==null?void 0:g.playlistVideoIndex)??0;if(i){const C=Number(w),u=r[C]||r[0];return{...s,projectId:n||"vp-player-projectId",video:{...s.video,file:u==null?void 0:u.hlsUrl,title:u==null?void 0:u.title,playlist:{state:!0,playlistId:"",playlistVideoIndex:Number(w),videos:r.slice(1).map((V,T)=>({videoId:String(T+1),title:V.title,file:V.hlsUrl,thumbnailUrl:V.thumbnailUrl,duration:V.duration}))}},config:c}}else return{...s,projectId:n||"vp-player-projectId",video:{...s.video,file:((P=r[Number(w)])==null?void 0:P.hlsUrl)||((b=r[0])==null?void 0:b.hlsUrl)||"",title:((f=r[Number(w)])==null?void 0:f.title)||((h=r[0])==null?void 0:h.title),thumbnail:((y=r[Number(w)])==null?void 0:y.thumbnailUrl)||((x=r[0])==null?void 0:x.thumbnailUrl),playlist:{state:!0,playlistVideoIndex:Number(w),videos:r.map((u,I)=>({videoId:String(I),title:u.title,file:u.hlsUrl,thumbnailUrl:u.thumbnailUrl,duration:u.duration}))}},config:c}}const d=((A=a==null?void 0:a.video)==null?void 0:A.playlist)||s.video.playlist,m=(R=a==null?void 0:a.video)==null?void 0:R.file;if(m)return{...s,video:{...s.video,file:m,playlist:void 0},config:c};if(d!=null&&d.videos&&d.videos.length>0){const w=d.videos[Number(d.playlistVideoIndex)||0];return{...s,video:{...s.video,file:(w==null?void 0:w.file)||"",playlist:{...d,state:d.state??!0,playlistVideoIndex:Number(d.playlistVideoIndex||0),videos:d.videos}},config:{...s.config,...a==null?void 0:a.config}}}throw new Error("No valid video source found. Provide videoUrl, videoId, playlistId, or config with video.file or playlist.")},ht=e=>{if(!e)return;const t=/https:\/\/host\.vpplayer\.tech\/player\/([^/]+)\/([^/]+)(?:\/[^/]+)?\.js/,r=e.match(t);return r?r[2]:void 0},mt=({playerId:e,videoId:t,version:r,videoUrl:n,projectId:a,playlistId:i,scriptUrl:s,config:c={},apiKey:d,isReels:m=!1})=>{const l=k.useRef(null),p=k.useRef(null),{isLoaded:g,error:P}=dt(r,s),b=t||ht(s),[f,h]=k.useState(null),{fetchedPlaybackUrl:y,fetchedPlaylist:x,isLoading:A,error:R}=ft({projectId:a,videoId:b,playlistId:i,videoUrl:n,apiKey:d}),w=Ne(e,b),C=k.useMemo(()=>{const u=c.config||{},I=m&&!u.size?{sizeType:"RESPONSIVE",aspectRatio:"9:16"}:u.size||{sizeType:"FIXED",width:"100%"};return{...c,config:{...u,size:I}}},[c,m]);return k.useEffect(()=>{if(P){h(P);return}if(!g||A&&!n)return;let u=!0;const V=setTimeout(async()=>{try{const T=s==null?void 0:s.includes("vertical-player");if(document.querySelectorAll('[id*="player"]').forEach(ae=>{var pe,he;const Z=ae.id;if(Z!==w)try{const o=T?(pe=window.vpVerticalPlayer)==null?void 0:pe.call(window,Z):(he=window.vpPlayer)==null?void 0:he.call(window,Z);o!=null&&o.destroy&&o.destroy()}catch(o){console.warn(`Failed to destroy existing player ${Z}:`,o)}}),await new Promise(ae=>setTimeout(ae,100)),!u||!l.current)return;if(!document.getElementById(w)){h("DOM element not found after cleanup.");return}if(!window.vpPlayer&&!window.vpVerticalPlayer){h("VP Player script not loaded.");return}const z=T?window.vpVerticalPlayer:window.vpPlayer;if(!z){h(`VP ${T?"Vertical ":""}Player script not loaded.`);return}const K=pt({videoUrl:n,fetchedPlaybackUrl:y??void 0,fetchedPlaylist:x??void 0,projectId:a,config:C,isVerticalPlayer:T}),ne=z(w);if(!ne){h(`Failed to create VP ${T?"Vertical ":""}Player instance.`);return}u&&l.current&&(ne.setup(K),p.current=ne,h(null))}catch(T){if(u){const L=T instanceof Error?T.message:String(T);h(L),console.error("VP Player initialization error:",T)}}},150);return()=>{u=!1,clearTimeout(V)}},[g,A,n,y,x,a,C,w,P,s]),k.useEffect(()=>()=>{if(p.current){try{p.current.destroy&&p.current.destroy()}catch(I){console.warn(`Failed to destroy player ${w}:`,I)}p.current=null}const u=document.getElementById(w);u&&(u.innerHTML="")},[w]),{playerRef:l,playerInstanceRef:p,isScriptLoaded:g,isLoading:A,error:R||f||P}},yt=({playerId:e,videoId:t,version:r,videoUrl:n,projectId:a,playlistId:i,scriptUrl:s,config:c={},apiKey:d,isReels:m=!1,hiddenClasses:l=[],onClose:p,className:g})=>{var V,T,L,X;const{playerRef:P,playerInstanceRef:b,isScriptLoaded:f,isLoading:h,error:y}=mt({playerId:e,videoId:t,version:r,videoUrl:n,projectId:a,playlistId:i,scriptUrl:s,config:c,apiKey:d,isReels:m}),[x,A]=k.useState(!0),R=()=>m&&A(!0),w=()=>{var z,K;A(!1),(K=(z=b.current)==null?void 0:z.play)==null||K.call(z),p==null||p()},C=(T=(V=c==null?void 0:c.config)==null?void 0:V.size)!=null&&T.width?typeof c.config.size.width=="number"?`${c.config.size.width}px`:c.config.size.width:void 0,u=(X=(L=c==null?void 0:c.config)==null?void 0:L.size)!=null&&X.height?typeof c.config.size.height=="number"?`${c.config.size.height}px`:c.config.size.height:void 0,I=Ne(e,t);return y?N.jsxs(je,{type:"error",children:["An error occurred: ",y]}):h||!f?N.jsx(je,{type:"loading",children:"Loading..."}):N.jsxs(N.Fragment,{children:[m&&!x?N.jsx("div",{onClick:R}):null,!m&&N.jsx("div",{children:N.jsx(Le,{id:I,ref:P,width:C||"100%",height:u||"auto",$hiddenClasses:l,className:g})},I),m&&x&&N.jsx(lt,{onClick:w,className:g,children:N.jsx(ut,{className:g,onClick:z=>z.stopPropagation(),children:N.jsx("div",{children:N.jsx(Le,{id:I,ref:P,width:"100%",height:"auto",$hiddenClasses:l,className:g})},I)})})]})},gt=k.createContext(void 0),_r=({children:e})=>{const[t,r]=k.useState(!1),[n,a]=k.useState(null),[i,s]=k.useState(null),c=k.useCallback(l=>{try{const p=Ne(l.playerId,l.videoId);a({...l,playerId:p}),r(!0),s(null)}catch{s("Failed to show player.")}},[]),d=k.useCallback(()=>{r(!1),a(null),s(null)},[]),m=k.useMemo(()=>({showPlayer:c,hidePlayer:d,isPlayerVisible:t,playerParams:n}),[c,d,t,n]);return N.jsxs(gt.Provider,{value:m,children:[e,i&&N.jsx(je,{type:"error",children:i}),t&&(n==null?void 0:n.playerId)&&N.jsx(yt,{playerId:n.playerId,videoId:n.videoId,projectId:n.projectId,videoUrl:n.videoUrl,version:n.version,playlistId:n.playlistId,scriptUrl:n.scriptUrl,config:n.config,isReels:n.isReels,thumbnailUrl:n.thumbnailUrl,onClose:d,hiddenClasses:n.hiddenClasses||[],apiKey:n.apiKey,className:n.className})]})},Sr=()=>{const e=k.useContext(gt);if(!e)throw new Error("useVPPlayer must be used within a VPPlayerProvider");return e},Ar={projectId:"vp-player-projectId",video:{file:"",playlist:{state:!0,playlistVideoIndex:0,videos:[]}},config:{autoplay:!0,pauseOtherVideos:!0,focusOnAutostart:!1,muted:!0,loop:!1,size:{width:"100%"},controls:{settingsButton:!0,chromecastButton:!1,nextButton:!1,fullscreenButton:!0,airplayButton:!1,bigPlayButton:!1,autopausePlayButton:!0,pictureInPictureButton:!1,relatedButton:!1,volumeButton:!0,shareButton:!0}}},Cr={config:{autostartOnLoad:{state:!0,onMobile:!0,onData:!0},muted:!0}},Tr={config:{autoplay:!0,muted:!0}},_e={video:{advertising:!0,ads:{skipAd:{state:!0,skipFrom:5}}},config:{adAnnouncement:{state:!0,timeBeforeAd:5},adsRequireInteraction:!1}},Rr=(e,t,r="time",n=0)=>{var a;return{..._e,video:{..._e.video,ads:{...(a=_e.video)==null?void 0:a.ads,adBreaks:[{adTagUrl:t,breakType:e,breakTimingType:r,breakTimingValue:n}]}}}},Ir="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",Or="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4",jr="https://videos.pexels.com/video-files/4678261/4678261-hd_1080_1920_25fps.mp4",Lr="https://images.pexels.com/videos/4678261/pexels-photo-4678261.jpeg?auto=compress&cs=tinysrgb&w=600",Nr="https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dlinear&correlator=",$r="https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dskippablelinear&correlator=";S.AD_TAG_LINEAR_URL=Nr,S.AD_TAG_SKIPPABLE_LINEAR_URL=$r,S.BIG_BUCK_BUNNY_URL=Ir,S.ELEPHANTS_DREAM_URL=Or,S.Overlay=lt,S.PEXELS_THUMBNAIL_URL=Lr,S.PEXELS_VERTICAL_VIDEO_URL=jr,S.PlayerContainer=Le,S.PlayerWrapper=ut,S.VPPlayer=yt,S.VPPlayerProvider=_r,S.baseConfig=Cr,S.baseConfigWithAds=_e,S.baseConfigWithAutoplay=Tr,S.buildVPPlayerConfig=pt,S.defaultVPPlayerConfig=Ar,S.extractVideoId=ht,S.getAdConfig=Rr,S.useVPPlayer=Sr,S.useVPPlayerLogic=mt,S.useVPPlayerScript=dt,S.useVideoData=ft,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
|
84
|
+
`,vr=(e,t)=>`https://vp-api.gjirafa.tech/api/v2/projects/${e}/videos?search=${t}`,wr=(e,t)=>`https://vp-api.gjirafa.tech/api/projects/${e}/playlists/${t}/videos`,xr=e=>`https://host.vpplayer.tech/player/${e}/vpplayer.js`,Ne=(e,t)=>`vp-player-${e||"default"}-${t||""}`,$e=new Map,dt=(e,t)=>{const[r,n]=k.useState(!1),[a,i]=k.useState(null);return k.useEffect(()=>{let s=null,c,d=0;const m=3;let l;try{l=t||xr(e||"latest")}catch(P){const b=P instanceof Error?P.message:String(P);i(`Failed to resolve script URL: ${b}`),n(!1);return}if($e.get(l)){n(!0),i(null);return}if(document.querySelector(`script[src="${l}"]`)){$e.set(l,!0),n(!0),i(null);return}const g=()=>{s=document.createElement("script"),s.src=l,s.async=!0,c=window.setTimeout(()=>{n(!1),i(`Loading script timed out: ${l}`)},1e4),s.onload=()=>{clearTimeout(c),$e.set(l,!0),n(!0),i(null)},s.onerror=()=>{clearTimeout(c),d++,d<m?setTimeout(g,1e3*d):(n(!1),i(`Failed to load VP Player script after ${m} attempts: ${l}`))},document.body.appendChild(s)};return g(),()=>{clearTimeout(c),s&&document.body.contains(s)&&document.body.removeChild(s)}},[e,t]),{isLoaded:r,error:a}},Pr={},Ee=new Map,kr=3e4,Ve=5,ft=({projectId:e,videoId:t,playlistId:r,videoUrl:n,apiKey:a})=>{const[i,s]=k.useState(null),[c,d]=k.useState(null),[m,l]=k.useState(!1),[p,g]=k.useState(null),P=a||(typeof Pr<"u"?"1CFC4B619E9342B6BAC4879BA8C30CF216C4BA9D3F084B11825F4AB2D5CF845E":void 0);return k.useEffect(()=>{const b=t?`video:${t}`:r?`playlist:${r}`:null;if(!e||n||!t&&!r){s(n||null),d(null),l(!1),g(null);return}if(!P){l(!1),g("No API key provided");return}if(b&&Ee.has(b)){const R=Ee.get(b);s(R.url),d(R.playlist),l(!1),g(null);return}let f=!0;const h=new AbortController,y=h.signal,A=setTimeout(async()=>{var w,C;if(!f)return;l(!0),g(null);let R=0;for(;R<Ve&&f;)try{const u=t&&!r?vr(e,t):wr(e,r),I=setTimeout(()=>h.abort(),kr),V=await fetch(u,{method:"GET",headers:{"api-key":P,Accept:"application/json","Cache-Control":"no-cache"},signal:y});if(clearTimeout(I),!V.ok)throw new Error(`Fetch failed with status ${V.status}`);const T=await V.json();if(!f)return;if(t&&!r){const L=(C=(w=T.result)==null?void 0:w.items)==null?void 0:C.find(X=>X.mediaId===t);if(!(L!=null&&L.playbackUrl))throw new Error("Invalid video data");s(L.playbackUrl),d(null),b&&Ee.set(b,{url:L.playbackUrl,playlist:null})}else{if(!Array.isArray(T.result))throw new Error("Invalid playlist format");d(T.result),s(null),b&&Ee.set(b,{url:null,playlist:T.result})}break}catch(u){if(y.aborted){f&&g("Request timed out");break}if(R++,R>=Ve){const I=u instanceof Error?u.message:String(u);f&&g(`Failed after ${Ve} attempts: ${I}`)}else await new Promise(I=>setTimeout(I,2e3))}f&&l(!1)},100);return()=>{f=!1,clearTimeout(A),h.abort()}},[P,e,t,r,n]),{fetchedPlaybackUrl:i,fetchedPlaylist:c,isLoading:m,error:p}},Er={projectId:"vp-player-projectId",video:{file:"",playlist:{state:!0,playlistVideoIndex:0,videos:[]}},config:{autoplay:!0,muted:!0,loop:!1,size:{width:"100%",height:"30vh"},controls:{settingsButton:!0,chromecastButton:!1,nextButton:!0,fullscreenButton:!0,airplayButton:!1,bigPlayButton:!1,autopausePlayButton:!0,pictureInPictureButton:!1,relatedButton:!1,volumeButton:!0,shareButton:!0}}},pt=({videoUrl:e,fetchedPlaybackUrl:t,fetchedPlaylist:r,projectId:n,config:a={},isVerticalPlayer:i})=>{var l,p,g,P,b,f,h,y,x,A,R;const s={...Er,...a},c={...s.config,...a.config};if(e)return{...s,video:{...s.video,file:e,playlist:void 0},config:c};if(t)return{...s,video:{...s.video,file:t,playlist:void 0},config:c};if(r&&r.length>0){const w=((p=(l=a==null?void 0:a.video)==null?void 0:l.playlist)==null?void 0:p.playlistVideoIndex)??((g=a==null?void 0:a.config)==null?void 0:g.playlistVideoIndex)??0;if(i){const C=Number(w),u=r[C]||r[0];return{...s,projectId:n||"vp-player-projectId",video:{...s.video,file:u==null?void 0:u.hlsUrl,title:u==null?void 0:u.title,playlist:{state:!0,playlistId:"",playlistVideoIndex:Number(w),videos:r.map((V,T)=>({videoId:String(T),title:V.title,file:V.hlsUrl,thumbnailUrl:V.thumbnailUrl,duration:V.duration}))}},config:c}}else return{...s,projectId:n||"vp-player-projectId",video:{...s.video,file:((P=r[Number(w)])==null?void 0:P.hlsUrl)||((b=r[0])==null?void 0:b.hlsUrl)||"",title:((f=r[Number(w)])==null?void 0:f.title)||((h=r[0])==null?void 0:h.title),thumbnail:((y=r[Number(w)])==null?void 0:y.thumbnailUrl)||((x=r[0])==null?void 0:x.thumbnailUrl),playlist:{state:!0,playlistVideoIndex:Number(w),videos:r.map((u,I)=>({videoId:String(I),title:u.title,file:u.hlsUrl,thumbnailUrl:u.thumbnailUrl,duration:u.duration}))}},config:c}}const d=((A=a==null?void 0:a.video)==null?void 0:A.playlist)||s.video.playlist,m=(R=a==null?void 0:a.video)==null?void 0:R.file;if(m)return{...s,video:{...s.video,file:m,playlist:void 0},config:c};if(d!=null&&d.videos&&d.videos.length>0){const w=d.videos[Number(d.playlistVideoIndex)||0];return{...s,video:{...s.video,file:(w==null?void 0:w.file)||"",playlist:{...d,state:d.state??!0,playlistVideoIndex:Number(d.playlistVideoIndex||0),videos:d.videos}},config:{...s.config,...a==null?void 0:a.config}}}throw new Error("No valid video source found. Provide videoUrl, videoId, playlistId, or config with video.file or playlist.")},ht=e=>{if(!e)return;const t=/https:\/\/host\.vpplayer\.tech\/player\/([^/]+)\/([^/]+)(?:\/[^/]+)?\.js/,r=e.match(t);return r?r[2]:void 0},mt=({playerId:e,videoId:t,version:r,videoUrl:n,projectId:a,playlistId:i,scriptUrl:s,config:c={},apiKey:d,isReels:m=!1})=>{const l=k.useRef(null),p=k.useRef(null),{isLoaded:g,error:P}=dt(r,s),b=t||ht(s),[f,h]=k.useState(null),{fetchedPlaybackUrl:y,fetchedPlaylist:x,isLoading:A,error:R}=ft({projectId:a,videoId:b,playlistId:i,videoUrl:n,apiKey:d}),w=Ne(e,b),C=k.useMemo(()=>{const u=c.config||{},I=m&&!u.size?{sizeType:"RESPONSIVE",aspectRatio:"9:16"}:u.size||{sizeType:"FIXED",width:"100%"};return{...c,config:{...u,size:I}}},[c,m]);return k.useEffect(()=>{if(P){h(P);return}if(!g||A&&!n)return;let u=!0;const V=setTimeout(async()=>{try{const T=s==null?void 0:s.includes("vertical-player");if(document.querySelectorAll('[id*="player"]').forEach(ae=>{var pe,he;const Z=ae.id;if(Z!==w)try{const o=T?(pe=window.vpVerticalPlayer)==null?void 0:pe.call(window,Z):(he=window.vpPlayer)==null?void 0:he.call(window,Z);o!=null&&o.destroy&&o.destroy()}catch(o){console.warn(`Failed to destroy existing player ${Z}:`,o)}}),await new Promise(ae=>setTimeout(ae,100)),!u||!l.current)return;if(!document.getElementById(w)){h("DOM element not found after cleanup.");return}if(!window.vpPlayer&&!window.vpVerticalPlayer){h("VP Player script not loaded.");return}const z=T?window.vpVerticalPlayer:window.vpPlayer;if(!z){h(`VP ${T?"Vertical ":""}Player script not loaded.`);return}const K=pt({videoUrl:n,fetchedPlaybackUrl:y??void 0,fetchedPlaylist:x??void 0,projectId:a,config:C,isVerticalPlayer:T}),ne=z(w);if(!ne){h(`Failed to create VP ${T?"Vertical ":""}Player instance.`);return}u&&l.current&&(ne.setup(K),p.current=ne,h(null))}catch(T){if(u){const L=T instanceof Error?T.message:String(T);h(L),console.error("VP Player initialization error:",T)}}},150);return()=>{u=!1,clearTimeout(V)}},[g,A,n,y,x,a,C,w,P,s]),k.useEffect(()=>()=>{if(p.current){try{p.current.destroy&&p.current.destroy()}catch(I){console.warn(`Failed to destroy player ${w}:`,I)}p.current=null}const u=document.getElementById(w);u&&(u.innerHTML="")},[w]),{playerRef:l,playerInstanceRef:p,isScriptLoaded:g,isLoading:A,error:R||f||P}},yt=({playerId:e,videoId:t,version:r,videoUrl:n,projectId:a,playlistId:i,scriptUrl:s,config:c={},apiKey:d,isReels:m=!1,hiddenClasses:l=[],onClose:p,className:g})=>{var V,T,L,X;const{playerRef:P,playerInstanceRef:b,isScriptLoaded:f,isLoading:h,error:y}=mt({playerId:e,videoId:t,version:r,videoUrl:n,projectId:a,playlistId:i,scriptUrl:s,config:c,apiKey:d,isReels:m}),[x,A]=k.useState(!0),R=()=>m&&A(!0),w=()=>{var z,K;A(!1),(K=(z=b.current)==null?void 0:z.play)==null||K.call(z),p==null||p()},C=(T=(V=c==null?void 0:c.config)==null?void 0:V.size)!=null&&T.width?typeof c.config.size.width=="number"?`${c.config.size.width}px`:c.config.size.width:void 0,u=(X=(L=c==null?void 0:c.config)==null?void 0:L.size)!=null&&X.height?typeof c.config.size.height=="number"?`${c.config.size.height}px`:c.config.size.height:void 0,I=Ne(e,t);return y?N.jsxs(je,{type:"error",children:["An error occurred: ",y]}):h||!f?N.jsx(je,{type:"loading",children:"Loading..."}):N.jsxs(N.Fragment,{children:[m&&!x?N.jsx("div",{onClick:R}):null,!m&&N.jsx("div",{children:N.jsx(Le,{id:I,ref:P,width:C||"100%",height:u||"auto",$hiddenClasses:l,className:g})},I),m&&x&&N.jsx(lt,{onClick:w,className:g,children:N.jsx(ut,{className:g,onClick:z=>z.stopPropagation(),children:N.jsx("div",{children:N.jsx(Le,{id:I,ref:P,width:"100%",height:"auto",$hiddenClasses:l,className:g})},I)})})]})},gt=k.createContext(void 0),_r=({children:e})=>{const[t,r]=k.useState(!1),[n,a]=k.useState(null),[i,s]=k.useState(null),c=k.useCallback(l=>{try{const p=Ne(l.playerId,l.videoId);a({...l,playerId:p}),r(!0),s(null)}catch{s("Failed to show player.")}},[]),d=k.useCallback(()=>{r(!1),a(null),s(null)},[]),m=k.useMemo(()=>({showPlayer:c,hidePlayer:d,isPlayerVisible:t,playerParams:n}),[c,d,t,n]);return N.jsxs(gt.Provider,{value:m,children:[e,i&&N.jsx(je,{type:"error",children:i}),t&&(n==null?void 0:n.playerId)&&N.jsx(yt,{playerId:n.playerId,videoId:n.videoId,projectId:n.projectId,videoUrl:n.videoUrl,version:n.version,playlistId:n.playlistId,scriptUrl:n.scriptUrl,config:n.config,isReels:n.isReels,thumbnailUrl:n.thumbnailUrl,onClose:d,hiddenClasses:n.hiddenClasses||[],apiKey:n.apiKey,className:n.className})]})},Sr=()=>{const e=k.useContext(gt);if(!e)throw new Error("useVPPlayer must be used within a VPPlayerProvider");return e},Ar={projectId:"vp-player-projectId",video:{file:"",playlist:{state:!0,playlistVideoIndex:0,videos:[]}},config:{autoplay:!0,pauseOtherVideos:!0,focusOnAutostart:!1,muted:!0,loop:!1,size:{width:"100%"},controls:{settingsButton:!0,chromecastButton:!1,nextButton:!1,fullscreenButton:!0,airplayButton:!1,bigPlayButton:!1,autopausePlayButton:!0,pictureInPictureButton:!1,relatedButton:!1,volumeButton:!0,shareButton:!0}}},Cr={config:{autostartOnLoad:{state:!0,onMobile:!0,onData:!0},muted:!0}},Tr={config:{autoplay:!0,muted:!0}},_e={video:{advertising:!0,ads:{skipAd:{state:!0,skipFrom:5}}},config:{adAnnouncement:{state:!0,timeBeforeAd:5},adsRequireInteraction:!1}},Rr=(e,t,r="time",n=0)=>{var a;return{..._e,video:{..._e.video,ads:{...(a=_e.video)==null?void 0:a.ads,adBreaks:[{adTagUrl:t,breakType:e,breakTimingType:r,breakTimingValue:n}]}}}},Ir="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",Or="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4",jr="https://videos.pexels.com/video-files/4678261/4678261-hd_1080_1920_25fps.mp4",Lr="https://images.pexels.com/videos/4678261/pexels-photo-4678261.jpeg?auto=compress&cs=tinysrgb&w=600",Nr="https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dlinear&correlator=",$r="https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dskippablelinear&correlator=";S.AD_TAG_LINEAR_URL=Nr,S.AD_TAG_SKIPPABLE_LINEAR_URL=$r,S.BIG_BUCK_BUNNY_URL=Ir,S.ELEPHANTS_DREAM_URL=Or,S.Overlay=lt,S.PEXELS_THUMBNAIL_URL=Lr,S.PEXELS_VERTICAL_VIDEO_URL=jr,S.PlayerContainer=Le,S.PlayerWrapper=ut,S.VPPlayer=yt,S.VPPlayerProvider=_r,S.baseConfig=Cr,S.baseConfigWithAds=_e,S.baseConfigWithAutoplay=Tr,S.buildVPPlayerConfig=pt,S.defaultVPPlayerConfig=Ar,S.extractVideoId=ht,S.getAdConfig=Rr,S.useVPPlayer=Sr,S.useVPPlayerLogic=mt,S.useVPPlayerScript=dt,S.useVideoData=ft,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
package/dist/App.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* Props for the FeedbackMessage component.
|
|
4
|
-
*/
|
|
5
|
-
interface FeedbackMessageProps {
|
|
6
|
-
type: "error" | "loading" | "success" | "warning";
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
className?: string;
|
|
9
|
-
icon?: ReactNode;
|
|
10
|
-
action?: ReactNode;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* FeedbackMessage component for displaying various types of messages (error, loading, success, warning).
|
|
14
|
-
* Can be customized with an icon, action button, and additional styles.
|
|
15
|
-
*
|
|
16
|
-
* @param {FeedbackMessageProps} props - The properties for the feedback message.
|
|
17
|
-
* @param {"error" | "loading" | "success" | "warning"} props.type - The type of message to display.
|
|
18
|
-
* @param {ReactNode} props.children - The content of the message.
|
|
19
|
-
* @param {string} [props.className] - Custom class for additional styling.
|
|
20
|
-
* @param {ReactNode} [props.icon] - Optional icon to display before the message.
|
|
21
|
-
* @param {ReactNode} [props.action] - Optional action button (e.g., "Retry").
|
|
22
|
-
* @returns {JSX.Element} The rendered feedback message component.
|
|
23
|
-
*/
|
|
24
|
-
export declare const FeedbackMessage: ({ type, children, className, icon, action }: FeedbackMessageProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./styled";
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Styled component for the video player container.
|
|
3
|
-
*
|
|
4
|
-
* @component
|
|
5
|
-
* @param {string} [width] - The width of the player (default: "100%").
|
|
6
|
-
* @param {string} [height] - The height of the player (default: "100%").
|
|
7
|
-
* @param {string[]} [$hiddenClasses] - CSS class names to hide elements inside the player.
|
|
8
|
-
* @param {string} [className] - CSS class name for additional styling.
|
|
9
|
-
*/
|
|
10
|
-
export declare const PlayerContainer: import("@emotion/styled").StyledComponent<{
|
|
11
|
-
theme?: import("@emotion/react").Theme;
|
|
12
|
-
as?: React.ElementType;
|
|
13
|
-
} & {
|
|
14
|
-
width?: string;
|
|
15
|
-
height?: string;
|
|
16
|
-
$hiddenClasses?: string[];
|
|
17
|
-
className?: string;
|
|
18
|
-
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
19
|
-
/**
|
|
20
|
-
* Styled component for the full-screen overlay when the player is active.
|
|
21
|
-
*
|
|
22
|
-
* @component
|
|
23
|
-
* @param {string} [className] - CSS class name for additional styling.
|
|
24
|
-
*/
|
|
25
|
-
export declare const Overlay: import("@emotion/styled").StyledComponent<{
|
|
26
|
-
theme?: import("@emotion/react").Theme;
|
|
27
|
-
as?: React.ElementType;
|
|
28
|
-
} & {
|
|
29
|
-
className?: string;
|
|
30
|
-
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
31
|
-
/**
|
|
32
|
-
* Styled wrapper for the player, adjusting its size based on viewport width.
|
|
33
|
-
*
|
|
34
|
-
* @component
|
|
35
|
-
* @param {string} [className] - CSS class name for additional styling.
|
|
36
|
-
*/
|
|
37
|
-
export declare const PlayerWrapper: import("@emotion/styled").StyledComponent<{
|
|
38
|
-
theme?: import("@emotion/react").Theme;
|
|
39
|
-
as?: React.ElementType;
|
|
40
|
-
} & {
|
|
41
|
-
className?: string;
|
|
42
|
-
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
package/dist/config/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./vpPlayerConfig";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { VPPlayerConfig } from '@/interfaces';
|
|
2
|
-
/**
|
|
3
|
-
* Default configuration for the VP Player.
|
|
4
|
-
*
|
|
5
|
-
* @constant
|
|
6
|
-
* @type {VPPlayerConfig}
|
|
7
|
-
* @see {@link https://vp.gjirafa.tech/documentation/docs/web-player/setup-the-player/configuration}
|
|
8
|
-
*/
|
|
9
|
-
export declare const defaultVPPlayerConfig: VPPlayerConfig;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { VPPlayerConfig } from "@/interfaces/config";
|
|
2
|
-
/**
|
|
3
|
-
* Base configuration for VP Player with common settings.
|
|
4
|
-
*/
|
|
5
|
-
export declare const baseConfig: Partial<VPPlayerConfig>;
|
|
6
|
-
/**
|
|
7
|
-
* Base configuration with autoplay enabled.
|
|
8
|
-
*/
|
|
9
|
-
export declare const baseConfigWithAutoplay: Partial<VPPlayerConfig>;
|
|
10
|
-
/**
|
|
11
|
-
* Base configuration for ads with common ad settings.
|
|
12
|
-
*/
|
|
13
|
-
export declare const baseConfigWithAds: Partial<VPPlayerConfig>;
|
|
14
|
-
/**
|
|
15
|
-
* Generates an ad configuration for VP Player based on provided parameters.
|
|
16
|
-
* @param breakType - The type of ad break (e.g., "preroll", "postroll", "midroll").
|
|
17
|
-
* @param adTagUrls - Array of ad tag URLs to use for the ad break.
|
|
18
|
-
* @param breakTimingType - The timing type for the ad break (e.g., "time", "percentage", "playlist").
|
|
19
|
-
* @param breakTimingValue - The timing value for the ad break (e.g., 0 for immediate, 2 for playlist index).
|
|
20
|
-
* @returns A partial VPPlayerConfig with the ad configuration.
|
|
21
|
-
*/
|
|
22
|
-
export declare const getAdConfig: (breakType: "preroll" | "postroll" | "midroll", adTagUrls: string[], breakTimingType?: "time" | "percentage" | "playlist", breakTimingValue?: number) => Partial<VPPlayerConfig>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./vpPlayer";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ArgTypes } from "@storybook/react";
|
|
2
|
-
/**
|
|
3
|
-
* Common Storybook argTypes used across stories.
|
|
4
|
-
*/
|
|
5
|
-
export declare const COMMON_ARGTYPES: Partial<ArgTypes<Record<string, unknown>>>;
|
|
6
|
-
/**
|
|
7
|
-
* Default API key and project ID for Storybook.
|
|
8
|
-
*/
|
|
9
|
-
export declare const DEFAULT_API_KEY: string;
|
|
10
|
-
export declare const DEFAULT_PLAYLIST_ID = "lzxikggu";
|
|
11
|
-
export declare const DEFAULT_PROJECT_ID = "agmipnxc";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Common styles for Storybook stories.
|
|
3
|
-
*/
|
|
4
|
-
/** Style for vertical playback containers (e.g., VerticalPlayback, VerticalPlaylistPlayback). */
|
|
5
|
-
export declare const VERTICAL_PLAYBACK_STYLE: React.CSSProperties;
|
|
6
|
-
/** Base style for multiple players containers (e.g., MultiplePlayersSideBySide, MultiplePlayersStacked). */
|
|
7
|
-
export declare const MULTIPLE_PLAYERS_BASE_STYLE: React.CSSProperties;
|
|
8
|
-
/** Style for side-by-side multiple players (e.g., MultiplePlayersSideBySide). */
|
|
9
|
-
export declare const MULTIPLE_PLAYERS_SIDE_BY_SIDE_STYLE: React.CSSProperties;
|
|
10
|
-
/** Style for stacked multiple players (e.g., MultiplePlayersStacked). */
|
|
11
|
-
export declare const MULTIPLE_PLAYERS_STACKED_STYLE: React.CSSProperties;
|
package/dist/constants/urls.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Constants for video URLs used across the application and Storybook stories.
|
|
3
|
-
*/
|
|
4
|
-
/** URL for the Big Buck Bunny video */
|
|
5
|
-
export declare const BIG_BUCK_BUNNY_URL = "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4";
|
|
6
|
-
/** URL for the Elephants Dream video */
|
|
7
|
-
export declare const ELEPHANTS_DREAM_URL = "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4";
|
|
8
|
-
/** URL for the Pexels vertical video */
|
|
9
|
-
export declare const PEXELS_VERTICAL_VIDEO_URL = "https://videos.pexels.com/video-files/4678261/4678261-hd_1080_1920_25fps.mp4";
|
|
10
|
-
/** URL for the Pexels thumbnail */
|
|
11
|
-
export declare const PEXELS_THUMBNAIL_URL = "https://images.pexels.com/videos/4678261/pexels-photo-4678261.jpeg?auto=compress&cs=tinysrgb&w=600";
|
|
12
|
-
/**
|
|
13
|
-
* Constants for ad tag URLs used in Storybook stories.
|
|
14
|
-
*/
|
|
15
|
-
/** Ad tag URL for linear ads */
|
|
16
|
-
export declare const AD_TAG_LINEAR_URL = "https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dlinear&correlator=";
|
|
17
|
-
/** Ad tag URL for skippable linear ads */
|
|
18
|
-
export declare const AD_TAG_SKIPPABLE_LINEAR_URL = "https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dskippablelinear&correlator=";
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates the URL for fetching a single video by projectId and videoId.
|
|
3
|
-
* @param {string} projectId - The project ID.
|
|
4
|
-
* @param {string} videoId - The video ID.
|
|
5
|
-
* @returns {string} - The complete API URL for single video fetch.
|
|
6
|
-
*/
|
|
7
|
-
export declare const getSingleVideoUrl: (projectId: string, videoId: string) => string;
|
|
8
|
-
/**
|
|
9
|
-
* Generates the URL for fetching a playlist by projectId and playlistId.
|
|
10
|
-
* @param {string} projectId - The project ID.
|
|
11
|
-
* @param {string} playlistId - The playlist ID.
|
|
12
|
-
* @returns {string} - The complete API URL for playlist fetch.
|
|
13
|
-
*/
|
|
14
|
-
export declare const getPlaylistUrl: (projectId: string, playlistId: string) => string;
|
|
15
|
-
/**
|
|
16
|
-
* Generates the URL for loading the VP Player script by version.
|
|
17
|
-
* @param {string} playerVersion - The version of the VP Player script (e.g., 'latest', 'v2.1.1').
|
|
18
|
-
* @returns {string} - The complete URL for the player script.
|
|
19
|
-
*/
|
|
20
|
-
export declare const getPlayerScriptUrl: (playerVersion: string) => string;
|
|
21
|
-
/**
|
|
22
|
-
* Generates a full player DOM element ID based on provided playerId and videoId.
|
|
23
|
-
* Falls back to "default" if playerId is not provided.
|
|
24
|
-
*
|
|
25
|
-
* @param playerId - Base identifier for the player.
|
|
26
|
-
* @param videoId - Optional video identifier.
|
|
27
|
-
* @returns Full DOM element ID string.
|
|
28
|
-
*/
|
|
29
|
-
export declare const generatePlayerId: (playerId?: string, videoId?: string) => string;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { VPPlayerProps } from "@/interfaces";
|
|
3
|
-
/**
|
|
4
|
-
* Interface defining the parameters for initializing the VPPlayer.
|
|
5
|
-
*
|
|
6
|
-
* @interface PlayerParams
|
|
7
|
-
*/
|
|
8
|
-
interface PlayerParams {
|
|
9
|
-
playerId?: string;
|
|
10
|
-
videoId?: string;
|
|
11
|
-
projectId?: string;
|
|
12
|
-
videoUrl?: string;
|
|
13
|
-
playlistId?: string;
|
|
14
|
-
scriptUrl?: string;
|
|
15
|
-
version?: string | null;
|
|
16
|
-
config?: VPPlayerProps["config"];
|
|
17
|
-
thumbnailUrl?: string;
|
|
18
|
-
isReels?: boolean;
|
|
19
|
-
hiddenClasses?: string[];
|
|
20
|
-
apiKey?: string;
|
|
21
|
-
className?: string;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Interface defining the context for VPPlayer.
|
|
25
|
-
*
|
|
26
|
-
* @interface VPPlayerContextType
|
|
27
|
-
*/
|
|
28
|
-
interface VPPlayerContextType {
|
|
29
|
-
showPlayer: (params: PlayerParams) => void;
|
|
30
|
-
hidePlayer: () => void;
|
|
31
|
-
isPlayerVisible: boolean;
|
|
32
|
-
playerParams: PlayerParams | null;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* VPPlayerProvider component provides context for managing the VPPlayer state.
|
|
36
|
-
*
|
|
37
|
-
* @function
|
|
38
|
-
* @param {Object} props - The component props.
|
|
39
|
-
* @param {React.ReactNode} props.children - The child components.
|
|
40
|
-
* @returns {JSX.Element} The provider component for VPPlayer.
|
|
41
|
-
*/
|
|
42
|
-
export declare const VPPlayerProvider: React.FC<{
|
|
43
|
-
children: React.ReactNode;
|
|
44
|
-
}>;
|
|
45
|
-
/**
|
|
46
|
-
* Hook for accessing the VPPlayer context.
|
|
47
|
-
*
|
|
48
|
-
* @function
|
|
49
|
-
* @throws {Error} If used outside of the VPPlayerProvider.
|
|
50
|
-
* @returns {VPPlayerContextType} The VPPlayer context.
|
|
51
|
-
*/
|
|
52
|
-
export declare const useVPPlayer: () => VPPlayerContextType;
|
|
53
|
-
export {};
|
package/dist/contexts/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./VPPlayerContext";
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { VPPlayerProps } from "@/interfaces";
|
|
2
|
-
/**
|
|
3
|
-
* Video Player Component for rendering a video player with overlay and responsive behavior.
|
|
4
|
-
* Handles initialization of the player and displays loading/error states.
|
|
5
|
-
*
|
|
6
|
-
* @function
|
|
7
|
-
* @param {VPPlayerProps} props - The properties for configuring the video player.
|
|
8
|
-
* @param {string} props.playerId - Unique identifier for the player instance.
|
|
9
|
-
* @param {string} [props.videoId] - ID of the video to be played.
|
|
10
|
-
* @param {string} [props.version] - Version of the player.
|
|
11
|
-
* @param {string} [props.videoUrl] - Direct video URL (bypasses API calls).
|
|
12
|
-
* @param {string} [props.projectId] - Project ID associated with the video.
|
|
13
|
-
* @param {string} [props.playlistId] - Playlist ID if playing a collection of videos.
|
|
14
|
-
* @param {string} [props.scriptUrl] - URL of the video player script.
|
|
15
|
-
* @param {object} [props.config={}] - Configuration settings for the player.
|
|
16
|
-
* @param {string} [props.apiKey] - API key for authentication (if required).
|
|
17
|
-
* @param {boolean} [props.isReels=false] - Determines if the player should behave as a short-video reel.
|
|
18
|
-
* @param {string[]} [props.hiddenClasses=[]] - CSS classes to hide player elements.
|
|
19
|
-
* @param {function} [props.onClose] - Callback triggered when the player is closed.
|
|
20
|
-
* @param {boolean} [props.isPlayerVisible=false] - Controls the initial visibility of the player.
|
|
21
|
-
* @param {string} [props.className] - CSS class name for additional styling.
|
|
22
|
-
* @returns {JSX.Element} The rendered video player component.
|
|
23
|
-
*/
|
|
24
|
-
declare const VPPlayer: ({ playerId, videoId, version, videoUrl, projectId, playlistId, scriptUrl, config, apiKey, isReels, hiddenClasses, onClose, className, }: VPPlayerProps & {
|
|
25
|
-
className?: string;
|
|
26
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
-
export default VPPlayer;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { VPPlayer } from "@/components/VPPlayer";
|
|
3
|
-
import { VPPlayerInstance } from "@/interfaces";
|
|
4
|
-
declare global {
|
|
5
|
-
interface Window {
|
|
6
|
-
vpPlayer?: (playerId: string) => VPPlayerInstance | undefined;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
declare const meta: Meta<typeof VPPlayer>;
|
|
10
|
-
export default meta;
|
|
11
|
-
type Story = StoryObj<typeof VPPlayer>;
|
|
12
|
-
export declare const SingleVideoOnePrerollAd: Story;
|
|
13
|
-
export declare const SingleVideoOnePostrollAd: Story;
|
|
14
|
-
export declare const SingleVideoMultiplePrerollAds: Story;
|
|
15
|
-
export declare const PlaylistOnePrerollEveryAd: Story;
|
|
16
|
-
export declare const PlaylistOneMidrollAd: Story;
|
|
17
|
-
export declare const PlaylistOnePostrollAddEveryVideo: Story;
|
|
18
|
-
export declare const PlaylistMultiplePrerollAdsEveryVideo: Story;
|
|
19
|
-
export declare const PlaylistMultipleMidrollAds: Story;
|
|
20
|
-
export declare const PictureInPictureDemoWithAds: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { VPPlayer } from "@/components/VPPlayer";
|
|
3
|
-
declare const meta: Meta<typeof VPPlayer>;
|
|
4
|
-
export default meta;
|
|
5
|
-
type Story = StoryObj<typeof VPPlayer>;
|
|
6
|
-
export declare const NoControlsSingleVideo: Story;
|
|
7
|
-
export declare const IsReelsWithContextPlaylistHiddenElements: Story;
|
|
8
|
-
export declare const IsReelsWithContextModalCentered: Story;
|
|
9
|
-
export declare const ContextWrapperModal: Story;
|
|
10
|
-
export declare const ContextCustomizedPortalPlayer: Story;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { VPPlayer } from "@/components/VPPlayer";
|
|
3
|
-
import { VPPlayerInstance } from "@/interfaces";
|
|
4
|
-
declare global {
|
|
5
|
-
interface Window {
|
|
6
|
-
vpPlayer?: (playerId: string) => VPPlayerInstance | undefined;
|
|
7
|
-
vpVerticalPlayer?: (playerId: string) => VPPlayerInstance | undefined;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
declare const meta: Meta<typeof VPPlayer>;
|
|
11
|
-
export default meta;
|
|
12
|
-
type Story = StoryObj<typeof VPPlayer>;
|
|
13
|
-
export declare const SingleVideoProvidedFile: Story;
|
|
14
|
-
export declare const SingleVideoAPI: Story;
|
|
15
|
-
export declare const PlaylistProvided: Story;
|
|
16
|
-
export declare const PlaylistAPI: Story;
|
|
17
|
-
export declare const HorizontalPlayback: Story;
|
|
18
|
-
export declare const VerticalPlayback: Story;
|
|
19
|
-
export declare const VerticalPlaylistPlayback: Story;
|
|
20
|
-
export declare const FloatingVideo: Story;
|
|
21
|
-
export declare const MultiplePlayersSideBySide: Story;
|
|
22
|
-
export declare const MultiplePlayersStacked: Story;
|
|
23
|
-
export declare const VerticalPlaylistTest: () => import("react/jsx-runtime").JSX.Element;
|
|
24
|
-
export declare const VerticalPlaylistTestSingleFile: () => import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
export declare const testPlayerControls: () => import("react/jsx-runtime").JSX.Element;
|
|
26
|
-
export declare const ptkzurta: () => import("react/jsx-runtime").JSX.Element;
|
|
27
|
-
export declare const VerticalPlaylistFastestWithPlaylistCheckOK: () => import("react/jsx-runtime").JSX.Element;
|
|
28
|
-
export declare const VerticalPlaylistOfficialConfig: () => import("react/jsx-runtime").JSX.Element;
|
|
29
|
-
export declare const PictureInPictureDemo: () => import("react/jsx-runtime").JSX.Element;
|
|
30
|
-
export declare const VerticalPlaylistStartFromIndexTestZimak: () => import("react/jsx-runtime").JSX.Element;
|
|
31
|
-
export declare const VerticalPlayerWithSubtitles: () => import("react/jsx-runtime").JSX.Element;
|
|
32
|
-
export declare const NormalPlayerWithSubtitles: () => import("react/jsx-runtime").JSX.Element;
|
|
33
|
-
export declare const VerticalPlaylistTestMainAndBackUp: () => import("react/jsx-runtime").JSX.Element;
|
package/dist/fixtures/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./playlist";
|
package/dist/hooks/index.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { VPPlayerInstance, VPPlayerProps } from "@/interfaces";
|
|
2
|
-
declare global {
|
|
3
|
-
interface Window {
|
|
4
|
-
vpPlayer?: (playerId: string) => VPPlayerInstance | undefined;
|
|
5
|
-
vpVerticalPlayer?: (playerId: string) => VPPlayerInstance | undefined;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Custom hook to manage VP Player logic, including fetching video data,
|
|
10
|
-
* initializing the player, and handling lifecycle events.
|
|
11
|
-
*
|
|
12
|
-
* @function
|
|
13
|
-
* @param {VPPlayerProps} props - The properties required to configure the VP Player.
|
|
14
|
-
* @returns {Object} An object containing player references, script loading status, loading state, and errors.
|
|
15
|
-
*/
|
|
16
|
-
export declare const useVPPlayerLogic: ({ playerId, videoId: propVideoId, version, videoUrl, projectId, playlistId, scriptUrl, config, apiKey, isReels, }: VPPlayerProps) => {
|
|
17
|
-
playerRef: import("react").RefObject<HTMLDivElement | null>;
|
|
18
|
-
playerInstanceRef: import("react").RefObject<VPPlayerInstance | null>;
|
|
19
|
-
isScriptLoaded: boolean;
|
|
20
|
-
isLoading: boolean;
|
|
21
|
-
error: string | null;
|
|
22
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Custom hook to dynamically load the VP Player script into the document.
|
|
3
|
-
* It ensures that the script is only loaded once and provides a loading state.
|
|
4
|
-
*
|
|
5
|
-
* @function
|
|
6
|
-
* @param {string | null} [version] - The version of the VP Player script to load (defaults to "latest").
|
|
7
|
-
* @param {string} [scriptUrl] - Custom script URL (if provided, it overrides the version-based URL).
|
|
8
|
-
* @returns {{ isLoaded: boolean; error: string | null }} Indicates load success and any error message.
|
|
9
|
-
*/
|
|
10
|
-
export declare const useVPPlayerScript: (version?: string | null, scriptUrl?: string) => {
|
|
11
|
-
isLoaded: boolean;
|
|
12
|
-
error: string | null;
|
|
13
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { VideoDataResult } from "@/types";
|
|
2
|
-
/**
|
|
3
|
-
* Custom hook for fetching video data, including playback URLs and playlists.
|
|
4
|
-
* Supports retry logic, timeout, error handling, and in-memory caching.
|
|
5
|
-
*
|
|
6
|
-
* @function
|
|
7
|
-
* @param {Object} params - The parameters for fetching video data.
|
|
8
|
-
* @param {string} [params.projectId] - The project ID required for API calls.
|
|
9
|
-
* @param {string} [params.videoId] - The video ID to fetch a single video's playback URL.
|
|
10
|
-
* @param {string} [params.playlistId] - The playlist ID to fetch a list of videos.
|
|
11
|
-
* @param {string} [params.videoUrl] - The direct video URL (skips API call if provided).
|
|
12
|
-
* @param {string} [params.apiKey] - The API key for authentication (optional, defaults to environment variable).
|
|
13
|
-
* @returns {VideoDataResult} - Result object with URL, playlist, loading and error states
|
|
14
|
-
*/
|
|
15
|
-
export declare const useVideoData: ({ projectId, videoId, playlistId, videoUrl, apiKey, }: {
|
|
16
|
-
projectId?: string;
|
|
17
|
-
videoId?: string;
|
|
18
|
-
playlistId?: string;
|
|
19
|
-
videoUrl?: string;
|
|
20
|
-
apiKey?: string;
|
|
21
|
-
}) => VideoDataResult;
|
package/dist/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { default as VPPlayer } from './features/VPPlayer';
|
|
2
|
-
export * from './components/VPPlayer/ui';
|
|
3
|
-
export { VPPlayerProvider, useVPPlayer } from './contexts/VPPlayerContext';
|
|
4
|
-
export * from './hooks';
|
|
5
|
-
export * from './interfaces';
|
|
6
|
-
export * from './types';
|
|
7
|
-
export * from './utils';
|
|
8
|
-
export * from './constants/configs';
|
|
9
|
-
export * from './constants/urls';
|
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Interface describing the advertising configuration options for the VP Player.
|
|
3
|
-
*
|
|
4
|
-
* @interface
|
|
5
|
-
* @see {@link https://vp.gjirafa.tech/documentation/docs/web-player/setup-the-player/advertising}
|
|
6
|
-
*/
|
|
7
|
-
export interface VPPlayerAdsConfig {
|
|
8
|
-
skipAd?: {
|
|
9
|
-
state: boolean;
|
|
10
|
-
skipFrom: number;
|
|
11
|
-
};
|
|
12
|
-
vmap?: string;
|
|
13
|
-
VPAIDmode?: string;
|
|
14
|
-
enableProgrammability?: boolean;
|
|
15
|
-
functions?: Array<{
|
|
16
|
-
isDynamicKey: boolean;
|
|
17
|
-
isDynamicValue: boolean;
|
|
18
|
-
key: string;
|
|
19
|
-
order: number;
|
|
20
|
-
value: string;
|
|
21
|
-
}>;
|
|
22
|
-
bidding?: boolean;
|
|
23
|
-
afterMidrollBacktrack?: {
|
|
24
|
-
state: boolean;
|
|
25
|
-
seconds: number;
|
|
26
|
-
};
|
|
27
|
-
adBreaks?: Array<{
|
|
28
|
-
adTagUrl: string[];
|
|
29
|
-
breakType?: 'preroll' | 'midroll' | 'postroll';
|
|
30
|
-
breakTimingType?: 'time' | 'percentage' | 'playlist';
|
|
31
|
-
breakTimingValue?: number;
|
|
32
|
-
schedule?: {
|
|
33
|
-
type?: 'CUSTOM' | 'RECURRING';
|
|
34
|
-
ranges?: Array<{
|
|
35
|
-
startTime?: number;
|
|
36
|
-
endTime?: number;
|
|
37
|
-
count?: number;
|
|
38
|
-
breaks?: number[];
|
|
39
|
-
}>;
|
|
40
|
-
algorithm?: 'PASSIVE' | 'AGGRESSIVE' | 'SIMILAR_DISTANCE' | 'CUSTOM';
|
|
41
|
-
protectFirst?: number;
|
|
42
|
-
protectLast?: number;
|
|
43
|
-
occurEvery?: number;
|
|
44
|
-
liveCount?: number;
|
|
45
|
-
};
|
|
46
|
-
}>;
|
|
47
|
-
bidders?: Array<{
|
|
48
|
-
name: string;
|
|
49
|
-
params?: Array<{
|
|
50
|
-
paramName?: string;
|
|
51
|
-
paramType?: string;
|
|
52
|
-
paramValue?: string;
|
|
53
|
-
}>;
|
|
54
|
-
}>;
|
|
55
|
-
adsRequireInteraction?: boolean;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Interface defining the configuration options for the VP Player.
|
|
59
|
-
*
|
|
60
|
-
* @interface
|
|
61
|
-
* @see {@link https://vp.gjirafa.tech/documentation/docs/web-player/setup-the-player/configuration}
|
|
62
|
-
* @see {@link https://vp.gjirafa.tech/documentation/docs/web-player/setup-the-player/playing}
|
|
63
|
-
* @see {@link https://vp.gjirafa.tech/documentation/docs/web-player/setup-the-player/advertising}
|
|
64
|
-
* @see {@link https://vp.gjirafa.tech/documentation/docs/web-player/setup-the-player/styling}
|
|
65
|
-
* @see {@link https://vp.gjirafa.tech/documentation/docs/web-player/setup-the-player/localization}
|
|
66
|
-
* @see {@link https://vp.gjirafa.tech/documentation/docs/web-player/setup-the-player/full-configuration}
|
|
67
|
-
*/
|
|
68
|
-
export interface VPPlayerConfig {
|
|
69
|
-
projectId?: string;
|
|
70
|
-
video: {
|
|
71
|
-
ads?: VPPlayerAdsConfig;
|
|
72
|
-
advertising?: boolean;
|
|
73
|
-
file?: string;
|
|
74
|
-
title?: string;
|
|
75
|
-
description?: string;
|
|
76
|
-
publishDate?: string;
|
|
77
|
-
duration?: number;
|
|
78
|
-
thumbnail?: string;
|
|
79
|
-
filmstrip?: string;
|
|
80
|
-
author?: string;
|
|
81
|
-
source?: string;
|
|
82
|
-
tags?: string[];
|
|
83
|
-
tracks?: Array<{
|
|
84
|
-
file: string;
|
|
85
|
-
label: string;
|
|
86
|
-
kind: string;
|
|
87
|
-
default?: boolean;
|
|
88
|
-
}>;
|
|
89
|
-
playlist?: {
|
|
90
|
-
state: boolean;
|
|
91
|
-
playlistVideoIndex: number;
|
|
92
|
-
videos: Array<{
|
|
93
|
-
videoId: string;
|
|
94
|
-
title: string;
|
|
95
|
-
thumbnailUrl?: string;
|
|
96
|
-
duration?: number;
|
|
97
|
-
file?: string;
|
|
98
|
-
}>;
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
config: {
|
|
102
|
-
adAnnouncement?: {
|
|
103
|
-
state?: boolean;
|
|
104
|
-
timeBeforeAd?: number;
|
|
105
|
-
};
|
|
106
|
-
autostartOnLoad?: {
|
|
107
|
-
state?: boolean;
|
|
108
|
-
onMobile?: boolean;
|
|
109
|
-
onData?: boolean;
|
|
110
|
-
};
|
|
111
|
-
adsRequireInteraction?: boolean;
|
|
112
|
-
autoplay?: boolean;
|
|
113
|
-
pauseOtherVideos?: boolean;
|
|
114
|
-
focusOnAutostart?: boolean;
|
|
115
|
-
muted?: boolean;
|
|
116
|
-
loop?: boolean;
|
|
117
|
-
size?: {
|
|
118
|
-
sizeType?: string;
|
|
119
|
-
aspectRatio?: string;
|
|
120
|
-
width?: number | string;
|
|
121
|
-
height?: number | string;
|
|
122
|
-
};
|
|
123
|
-
showRelatedOnPause?: {
|
|
124
|
-
state?: boolean;
|
|
125
|
-
onMobile?: boolean;
|
|
126
|
-
from?: number;
|
|
127
|
-
};
|
|
128
|
-
float?: {
|
|
129
|
-
state: boolean;
|
|
130
|
-
onMobile: boolean;
|
|
131
|
-
position: string;
|
|
132
|
-
dismissible: boolean;
|
|
133
|
-
requiresInteraction: boolean;
|
|
134
|
-
toVideoThreshold: number;
|
|
135
|
-
toFloatThreshold: number;
|
|
136
|
-
style: {
|
|
137
|
-
width: number;
|
|
138
|
-
border: string;
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
controls?: {
|
|
142
|
-
theaterButton?: boolean;
|
|
143
|
-
settingsButton?: boolean;
|
|
144
|
-
chromecastButton?: boolean;
|
|
145
|
-
nextButton?: boolean;
|
|
146
|
-
fullscreenButton?: boolean;
|
|
147
|
-
airplayButton?: boolean;
|
|
148
|
-
bigPlayButton?: boolean;
|
|
149
|
-
autopausePlayButton?: boolean;
|
|
150
|
-
pictureInPictureButton?: boolean;
|
|
151
|
-
relatedButton?: boolean;
|
|
152
|
-
volumeButton?: boolean;
|
|
153
|
-
shareButton?: boolean;
|
|
154
|
-
subtitlesButton?: boolean;
|
|
155
|
-
showCaptions?: boolean;
|
|
156
|
-
};
|
|
157
|
-
logo?: {
|
|
158
|
-
state?: boolean;
|
|
159
|
-
file?: string;
|
|
160
|
-
position?: string;
|
|
161
|
-
defaultOpacity?: number;
|
|
162
|
-
inactiveOpacity?: number;
|
|
163
|
-
onClickURL?: string;
|
|
164
|
-
};
|
|
165
|
-
skin?: {
|
|
166
|
-
controlBar?: {
|
|
167
|
-
background?: string;
|
|
168
|
-
spread?: "solid" | "gradient";
|
|
169
|
-
gradientMidPoint?: number;
|
|
170
|
-
text?: string;
|
|
171
|
-
icons?: {
|
|
172
|
-
default?: string;
|
|
173
|
-
hover?: string;
|
|
174
|
-
};
|
|
175
|
-
timeslider?: {
|
|
176
|
-
progress?: string;
|
|
177
|
-
rail?: string;
|
|
178
|
-
buffer?: string;
|
|
179
|
-
dragger?: string;
|
|
180
|
-
};
|
|
181
|
-
timesliderOnAd?: {
|
|
182
|
-
progress?: string;
|
|
183
|
-
rail?: string;
|
|
184
|
-
buffer?: string;
|
|
185
|
-
dragger?: string;
|
|
186
|
-
};
|
|
187
|
-
volume?: {
|
|
188
|
-
dragger?: string;
|
|
189
|
-
progress?: string;
|
|
190
|
-
rail?: string;
|
|
191
|
-
notifier?: string;
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
menus?: {
|
|
195
|
-
background?: {
|
|
196
|
-
default?: string;
|
|
197
|
-
hover?: string;
|
|
198
|
-
};
|
|
199
|
-
links?: {
|
|
200
|
-
default?: string;
|
|
201
|
-
hover?: string;
|
|
202
|
-
};
|
|
203
|
-
autoplay?: {
|
|
204
|
-
autoplayOn?: string;
|
|
205
|
-
autoplayOff?: string;
|
|
206
|
-
};
|
|
207
|
-
};
|
|
208
|
-
nextVideo?: {
|
|
209
|
-
background?: string;
|
|
210
|
-
text?: string;
|
|
211
|
-
timeslider?: {
|
|
212
|
-
rail?: string;
|
|
213
|
-
progress?: string;
|
|
214
|
-
};
|
|
215
|
-
icons?: {
|
|
216
|
-
play?: {
|
|
217
|
-
default?: string;
|
|
218
|
-
hover?: string;
|
|
219
|
-
};
|
|
220
|
-
close?: string;
|
|
221
|
-
};
|
|
222
|
-
};
|
|
223
|
-
playlist?: {
|
|
224
|
-
background?: string;
|
|
225
|
-
text?: string;
|
|
226
|
-
icons?: {
|
|
227
|
-
arrows?: {
|
|
228
|
-
active?: string;
|
|
229
|
-
inactive?: string;
|
|
230
|
-
};
|
|
231
|
-
close?: string;
|
|
232
|
-
};
|
|
233
|
-
card?: {
|
|
234
|
-
background?: string;
|
|
235
|
-
title?: string;
|
|
236
|
-
duration?: {
|
|
237
|
-
text?: string;
|
|
238
|
-
background?: string;
|
|
239
|
-
};
|
|
240
|
-
icons?: {
|
|
241
|
-
play?: {
|
|
242
|
-
default?: string;
|
|
243
|
-
hover?: string;
|
|
244
|
-
};
|
|
245
|
-
};
|
|
246
|
-
};
|
|
247
|
-
};
|
|
248
|
-
};
|
|
249
|
-
lang?: {
|
|
250
|
-
locale?: string;
|
|
251
|
-
controls?: {
|
|
252
|
-
play?: string;
|
|
253
|
-
pause?: string;
|
|
254
|
-
next?: string;
|
|
255
|
-
replay?: string;
|
|
256
|
-
volume?: string;
|
|
257
|
-
mute?: string;
|
|
258
|
-
unmute?: string;
|
|
259
|
-
settings?: string;
|
|
260
|
-
theater?: string;
|
|
261
|
-
fullscreen?: string;
|
|
262
|
-
chromecast?: string;
|
|
263
|
-
airplay?: string;
|
|
264
|
-
pictureInPicture?: string;
|
|
265
|
-
related?: string;
|
|
266
|
-
skipIntro?: string;
|
|
267
|
-
skipAd?: string;
|
|
268
|
-
playlistTitle?: string;
|
|
269
|
-
upNext?: string;
|
|
270
|
-
live?: string;
|
|
271
|
-
continueAfterPause?: string;
|
|
272
|
-
};
|
|
273
|
-
settings?: {
|
|
274
|
-
quality?: string;
|
|
275
|
-
subtitles?: string;
|
|
276
|
-
autoplay?: string;
|
|
277
|
-
playbackRate?: string;
|
|
278
|
-
auto?: string;
|
|
279
|
-
off?: string;
|
|
280
|
-
normal?: string;
|
|
281
|
-
share?: string;
|
|
282
|
-
};
|
|
283
|
-
ads?: {
|
|
284
|
-
ad?: string;
|
|
285
|
-
skip?: string;
|
|
286
|
-
skipIn?: string;
|
|
287
|
-
visit?: string;
|
|
288
|
-
info?: string;
|
|
289
|
-
simultaneousAds?: string;
|
|
290
|
-
adAnnouncement?: string;
|
|
291
|
-
};
|
|
292
|
-
messages?: {
|
|
293
|
-
playbackErrorTitle?: string;
|
|
294
|
-
playbackErrorDescription?: string;
|
|
295
|
-
geoBlockedTitle?: string;
|
|
296
|
-
geoBlockedDescription?: string;
|
|
297
|
-
streamInterruptedTitle?: string;
|
|
298
|
-
streamInterruptedDescription?: string;
|
|
299
|
-
};
|
|
300
|
-
};
|
|
301
|
-
ads?: VPPlayerAdsConfig;
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Default configuration object for the VP Player.
|
|
306
|
-
*
|
|
307
|
-
* @constant
|
|
308
|
-
* @type {VPPlayerConfig}
|
|
309
|
-
* @see {@link https://vp.gjirafa.tech/documentation/docs/web-player/setup-the-player/configuration}
|
|
310
|
-
*/
|
|
311
|
-
export declare const defaultVPPlayerConfig: VPPlayerConfig;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { VPPlayerConfig } from "./config";
|
|
2
|
-
/**
|
|
3
|
-
* Interface representing an instance of the VP Player.
|
|
4
|
-
* Based on VP Player API Reference: https://vp.gjirafa.tech/documentation/docs/web-player/api-reference
|
|
5
|
-
* And VP Vertical Player API Reference: https://vp.gjirafa.tech/documentation/docs/vertical-player/api-reference
|
|
6
|
-
*
|
|
7
|
-
* @interface
|
|
8
|
-
*/
|
|
9
|
-
export interface VPPlayerInstance {
|
|
10
|
-
setup: (config: VPPlayerConfig) => void;
|
|
11
|
-
destroy?: () => void;
|
|
12
|
-
play?: () => void;
|
|
13
|
-
pause?: () => void;
|
|
14
|
-
forward?: () => void;
|
|
15
|
-
rewind?: () => void;
|
|
16
|
-
replay?: () => void;
|
|
17
|
-
seek?: (position: number) => void;
|
|
18
|
-
mute?: () => void;
|
|
19
|
-
unmute?: () => void;
|
|
20
|
-
enterFullScreen?: () => void;
|
|
21
|
-
exitFullScreen?: () => void;
|
|
22
|
-
enterFullscreen?: () => void;
|
|
23
|
-
exitFullscreen?: () => void;
|
|
24
|
-
enterPictureInPicture?: () => void;
|
|
25
|
-
exitPictureInPicture?: () => void;
|
|
26
|
-
floating?: () => void;
|
|
27
|
-
isFloating?: () => boolean;
|
|
28
|
-
getFloatStyle?: () => unknown;
|
|
29
|
-
setFloatingHlsLevels?: (levels: unknown) => void;
|
|
30
|
-
floatingStateCounter?: number;
|
|
31
|
-
nextVideo?: () => void;
|
|
32
|
-
previousVideo?: () => void;
|
|
33
|
-
switchToIndex?: (index: number) => void;
|
|
34
|
-
switch?: (video: unknown) => void;
|
|
35
|
-
playNewVideo?: (video: unknown) => void;
|
|
36
|
-
togglePlay?: () => void;
|
|
37
|
-
toggleMute?: () => void;
|
|
38
|
-
isMuted?: () => boolean;
|
|
39
|
-
isPlaying?: () => boolean;
|
|
40
|
-
isPaused?: () => boolean;
|
|
41
|
-
isFullscreen?: () => boolean;
|
|
42
|
-
isEnded?: () => boolean;
|
|
43
|
-
isFocused?: () => boolean;
|
|
44
|
-
getPosition?: () => number;
|
|
45
|
-
getBuffered?: () => number;
|
|
46
|
-
getVolume?: () => number;
|
|
47
|
-
getContainer?: () => HTMLElement;
|
|
48
|
-
getDuration?: () => number;
|
|
49
|
-
getQualityLevels?: () => unknown[];
|
|
50
|
-
getCurrentQuality?: () => number;
|
|
51
|
-
checkViewability?: () => boolean;
|
|
52
|
-
setConfig?: (config: unknown) => void;
|
|
53
|
-
setVideo?: (video: unknown) => void;
|
|
54
|
-
setPlaylist?: (playlist: unknown) => void;
|
|
55
|
-
setVolume?: (volume: number) => void;
|
|
56
|
-
setCurrentQuality?: (index: number) => void;
|
|
57
|
-
setLevelToAuto?: () => void;
|
|
58
|
-
setCuePoint?: (cue: number, callback: () => void) => void;
|
|
59
|
-
on?: (event: string, callback: (data?: unknown) => void) => void;
|
|
60
|
-
off?: (event: string, callback?: (data?: unknown) => void) => void;
|
|
61
|
-
videoIndex?: number;
|
|
62
|
-
playlist?: {
|
|
63
|
-
state: boolean;
|
|
64
|
-
playlistId: string;
|
|
65
|
-
playlistVideoIndex: number;
|
|
66
|
-
videos: unknown[];
|
|
67
|
-
};
|
|
68
|
-
multipleVideos?: Map<number, unknown>;
|
|
69
|
-
firstInList?: boolean;
|
|
70
|
-
lastInList?: boolean;
|
|
71
|
-
setupComplete?: boolean;
|
|
72
|
-
initialized?: boolean;
|
|
73
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { VPPlayerConfig } from "./config";
|
|
2
|
-
/**
|
|
3
|
-
* Interface defining the parameters for configuring the VP Player instance.
|
|
4
|
-
*
|
|
5
|
-
* @interface
|
|
6
|
-
*/
|
|
7
|
-
export interface PlayerParams {
|
|
8
|
-
playerId?: string;
|
|
9
|
-
videoId?: string;
|
|
10
|
-
projectId?: string;
|
|
11
|
-
videoUrl?: string;
|
|
12
|
-
playlistId?: string;
|
|
13
|
-
scriptUrl?: string;
|
|
14
|
-
version?: string | null;
|
|
15
|
-
config?: Partial<VPPlayerConfig>;
|
|
16
|
-
thumbnailUrl?: string;
|
|
17
|
-
isReels?: boolean;
|
|
18
|
-
hiddenClasses?: string[];
|
|
19
|
-
apiKey?: string;
|
|
20
|
-
className?: string;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Interface for the VP Player context, providing methods and state for controlling the player.
|
|
24
|
-
*
|
|
25
|
-
* @interface
|
|
26
|
-
*/
|
|
27
|
-
export interface VPPlayerContextType {
|
|
28
|
-
showPlayer: (params: PlayerParams) => void;
|
|
29
|
-
hidePlayer: () => void;
|
|
30
|
-
isPlayerVisible: boolean;
|
|
31
|
-
playerParams: PlayerParams | null;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Interface defining the properties for the VP Player component.
|
|
35
|
-
*
|
|
36
|
-
* @interface
|
|
37
|
-
*/
|
|
38
|
-
export interface VPPlayerProps {
|
|
39
|
-
playerId: string;
|
|
40
|
-
videoId?: string;
|
|
41
|
-
projectId?: string;
|
|
42
|
-
videoUrl?: string;
|
|
43
|
-
playlistId?: string;
|
|
44
|
-
scriptUrl?: string;
|
|
45
|
-
version?: string | null;
|
|
46
|
-
config?: Partial<VPPlayerConfig>;
|
|
47
|
-
isReels?: boolean;
|
|
48
|
-
thumbnailUrl?: string;
|
|
49
|
-
onClose?: () => void;
|
|
50
|
-
hiddenClasses?: string[];
|
|
51
|
-
apiKey?: string;
|
|
52
|
-
isPlayerVisible?: boolean;
|
|
53
|
-
className?: string;
|
|
54
|
-
}
|
package/dist/main.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./index.css";
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* API response types for VP Player.
|
|
3
|
-
*
|
|
4
|
-
* @interface VideoApiItem
|
|
5
|
-
* Represents an individual video item in the API response.
|
|
6
|
-
*/
|
|
7
|
-
export interface VideoApiItem {
|
|
8
|
-
mediaId: string;
|
|
9
|
-
playbackUrl: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* API response structure for fetching video data.
|
|
13
|
-
*
|
|
14
|
-
* @interface VideoApiResponse
|
|
15
|
-
*/
|
|
16
|
-
export interface VideoApiResponse {
|
|
17
|
-
result: {
|
|
18
|
-
items: VideoApiItem[];
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Represents an item in a video playlist.
|
|
23
|
-
*
|
|
24
|
-
* @interface PlaylistItem
|
|
25
|
-
*/
|
|
26
|
-
export interface PlaylistItem {
|
|
27
|
-
title: string;
|
|
28
|
-
hlsUrl: string;
|
|
29
|
-
thumbnailUrl: string;
|
|
30
|
-
duration: number;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* API response structure for fetching playlist data.
|
|
34
|
-
*
|
|
35
|
-
* @interface PlaylistApiResponse
|
|
36
|
-
*/
|
|
37
|
-
export interface PlaylistApiResponse {
|
|
38
|
-
result: PlaylistItem[];
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Result structure returned by the video data fetching logic.
|
|
42
|
-
*
|
|
43
|
-
* @interface VideoDataResult
|
|
44
|
-
*/
|
|
45
|
-
export interface VideoDataResult {
|
|
46
|
-
fetchedPlaybackUrl: string | null;
|
|
47
|
-
fetchedPlaylist: PlaylistItem[] | null;
|
|
48
|
-
isLoading: boolean;
|
|
49
|
-
error: string | null;
|
|
50
|
-
}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./api.types";
|
package/dist/utils/index.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { VPPlayerConfig } from "@/interfaces";
|
|
2
|
-
import { PlaylistItem } from "@/types";
|
|
3
|
-
/**
|
|
4
|
-
* Interface for options used in building the VP Player configuration.
|
|
5
|
-
*
|
|
6
|
-
* @interface ConfigBuilderOptions
|
|
7
|
-
*/
|
|
8
|
-
interface ConfigBuilderOptions {
|
|
9
|
-
videoUrl?: string;
|
|
10
|
-
fetchedPlaybackUrl?: string;
|
|
11
|
-
fetchedPlaylist?: PlaylistItem[];
|
|
12
|
-
projectId?: string;
|
|
13
|
-
config?: Partial<VPPlayerConfig>;
|
|
14
|
-
isVerticalPlayer?: boolean;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Builds the final VP Player configuration based on available data.
|
|
18
|
-
* Handles different data sources in priority order:
|
|
19
|
-
* 1. Direct video URL
|
|
20
|
-
* 2. Single video from API
|
|
21
|
-
* 3. Playlist from API
|
|
22
|
-
* 4. Playlist from config
|
|
23
|
-
*
|
|
24
|
-
* @function
|
|
25
|
-
* @param {ConfigBuilderOptions} options - Options for building the configuration
|
|
26
|
-
* @returns {VPPlayerConfig} - The final configuration object for the player
|
|
27
|
-
* @throws {Error} - Throws error if no valid video source is found
|
|
28
|
-
*/
|
|
29
|
-
export declare const buildVPPlayerConfig: ({ videoUrl, fetchedPlaybackUrl, fetchedPlaylist, projectId, config, isVerticalPlayer, }: ConfigBuilderOptions) => VPPlayerConfig;
|
|
30
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts the video ID from a given VP Player script URL.
|
|
3
|
-
*
|
|
4
|
-
* @function
|
|
5
|
-
* @param {string} [scriptUrl] - The script URL containing the video ID.
|
|
6
|
-
* @returns {string | undefined} The extracted video ID, or `undefined` if not found.
|
|
7
|
-
*/
|
|
8
|
-
export declare const extractVideoId: (scriptUrl?: string) => string | undefined;
|