cloudinary-video-player
Version:
Cloudinary Video Player
2 lines • 8.76 kB
JavaScript
(self.cloudinaryVideoPlayerChunkLoading=self.cloudinaryVideoPlayerChunkLoading||[]).push([[404],{9017:(t,e,n)=>{"use strict";n.d(e,{F0:()=>r,Fg:()=>a,IT:()=>s,T$:()=>l,Vv:()=>d,Yx:()=>c,be:()=>o,q3:()=>u,sb:()=>i});const i="cld-ia-layout-state",o="vp-ia",a="interaction-areas-container",r={PORTRAIT:"portrait",LANDSCAPE:"landscape",All:"all",CENTER:"center"},s={PULSING:"pulsing",SHADOWED:"shadowed"},c={[r.PORTRAIT]:"https://res.cloudinary.com/prod/raw/upload/v1623772481/video-player/vtts/portrait.vtt",[r.LANDSCAPE]:"https://res.cloudinary.com/prod/raw/upload/v1623772303/video-player/vtts/landscape.vtt",[r.All]:"https://res.cloudinary.com/prod/raw/upload/v1623250266/video-player/vtts/all.vtt",[r.CENTER]:"https://res.cloudinary.com/prod/raw/upload/v1623250265/video-player/vtts/center.vtt"},l="https://res.cloudinary.com/prod/image/upload/v1626764643/video-player/interaction-area-hand.svg",d=4500,u=250},1066:(t,e,n)=>{"use strict";n.d(e,{interactionAreasService:()=>C});var i=n(6673),o=n.n(i),a=n(2832),r=n.n(a),s=n(2858),c=n.n(s),l=n(5114),d=n.n(l),u=n(9017),v=n(7134),p=n(4500);const h=t=>{let{text:e,onClick:n,theme:i="",loadingDelay:o=0}=t;return(0,v.It)({tag:"button",attr:{class:`vp-theme-button theme-${i}`},onClick:n,children:[{tag:"div",attr:{class:"vp-loading-bar"},style:{"animation-duration":`${o}ms`}},{tag:"div",attr:{class:"content"},children:e}]})},f="transparent-white",m=(t,e)=>t.id||t.type||`id_${e}`,g=(t,e,n,i,o)=>{let{playerOptions:a,videojsOptions:s}=t;const c=(0,p.w)(s),l=a&&a.colors?a.colors.accent:c.accent,d=r()(s,"interactionDisplay.theme.template",u.IT.PULSING);return(0,v.It)({tag:"div",attr:{class:`${u.be}-item theme-${d}`,"data-id":m(e,n)},style:{left:`${e.left}%`,top:`${e.top}%`,width:`${e.width}%`,height:`${e.height}%`,transitionDuration:`${i}ms`},event:{name:"click",callback:o},children:[{tag:"div",attr:{class:`${u.be}-area-marker`},children:[{tag:"div",attr:{class:`${u.be}-marker-shadow`},style:{[d===u.IT.SHADOWED?"backgroundColor":"borderColor"]:l}},{tag:"div",attr:{class:`${u.be}-marker-main`},style:{borderColor:l}}]}]})},y=(t,e)=>t/(100/+e),b=(t,e)=>{const n=x(t);n?n.replaceWith(e):t.el().appendChild(e)},T=(t,e,n)=>t.querySelector(`[data-id=${m(e,n)}]`),$=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d();localStorage.setItem(u.sb,JSON.parse(t)),e()},x=t=>t.el().querySelector(`.${u.Fg}`),E=t=>{const e=x(t);e&&e.parentNode.removeChild(e)};var w=n(8838),k=n(1104);const C=(t,e,n)=>{let i=!1,a=null,s=null,l=d();const p=()=>{return t=n.interactionDisplay,r()(t,"layout.enable",!0)&&"true"!==localStorage.getItem(u.sb);var t},C=()=>{const t=D();return!(!t||void 0===t.syncOffsetTime)&&t.syncOffsetTime};function j(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const e=D();return t||e&&e.enable}function A(){s&&t.videojs.removeRemoteTextTrack(s);const e=j(),n=D();if(!e||i)return null;if(Array.isArray(n.template))L(n.template),M();else{const e=n.vttUrl||u.Yx[n.template];e&&(s=(0,w.eo)(t.videojs,e),function(e){if(!e)return;let n=null;e.addEventListener("cuechange",(()=>{const i=e.activeCues&&e.activeCues[0];if(i){const t=Math.max(Math.floor(1e3*(i.endTime-i.startTime)),u.q3),e=JSON.parse(i.text);L(e,n,t),!n&&M(),n=e}else E(t.videojs),n=null}))}(s))}}function D(){const{cldSrc:t}=a;return t&&t.getInteractionAreas()}function I(){E(t.videojs),A(),t.play()}function S(){if(j())if(p()){let e=null;const i=r()(n,"interactionDisplay.layout.showAgain",!1);t.pause(),function(t,e){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=!1;const o=`checkbox_${Math.round(1e4*Math.random())}`,a=(0,v.It)({tag:"div",attr:{class:`${u.Fg} ${u.be}-layout-message ${n?"":"clickable"}`},onClick:n?null:()=>$(i,e),children:[{tag:"img",attr:{class:`${u.be}-layout-icon`,src:u.T$}},{tag:"h3",attr:{class:`${u.be}-layout-message-title`},children:"Tap on dots to zoom for a product."},h({text:"Got it",theme:f,loadingDelay:n?0:u.Vv,onClick:n?()=>$(i,e):null}),n&&{tag:"div",attr:{class:`${u.be}-layout-message-do-not-show`},children:[{tag:"input",attr:{type:"checkbox",class:`${u.be}-layout-message-checkbox`,id:o},event:{name:"input",callback:t=>{i=t.target.checked}}},{tag:"label",attr:{class:`${u.be}-layout-message-checkbox-title`,for:o},children:"Don׳t show it again"}]}].filter((t=>t))});b(t,a)}(t.videojs,(()=>{clearTimeout(e),I()}),i),i||(e=setTimeout(I,u.Vv))}else I()}function O(e,n,r){const s=t.currentTime(),c=C(),{cldSrc:d}=a,p=d.getInitOptions(),h=n||{transformation:p.transformation},f=!e&&((t,e)=>{const{videoHeight:n,videoWidth:i}=t,o=y(i,e.left),a=y(n,e.top),r=y(i,e.width),s=y(n,e.height),c=i/n,l=r/s,d=Math.round(l>1||c>1?s*l:r),u=Math.round(d/c),v=Math.round(o-(d-r)/2),p=Math.round(a-(u-s)/2);return{width:d,height:u,x:Math.min(Math.max(v,0),i-d),y:Math.min(Math.max(p,0),n-u),crop:"crop"}})(t.videoElement,r),m=f?o().obj.merge({transformation:f},h):h,g=d.isRawUrl?a.src:{publicId:d.publicId()};t.source(f?{publicId:d.publicId()}:e,m).play(),c&&t.currentTime(s),i=!0,function(){const e=(0,v.n)("div",{class:"go-back-button"});e.addEventListener("click",(()=>{l()}),!1);const n=(0,v.n)("div",{class:u.Fg},e);b(t.videojs,n)}(),l=()=>{if(i){i=!1;const e=t.currentTime(),n=t.duration();t.source(g,p).play(),c&&e<n&&t.currentTime(e),A()}}}function N(t){let{event:e,item:n,index:i}=t;const o=D();o.onClick&&o.onClick({item:n,index:i,event:e,zoom:(t,e)=>{O(t,e,n)}})}function L(i,o){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const r={playerOptions:e,videojsOptions:n};if(o)((t,e,n,i,o,a)=>{const r=x(t);n.forEach(((t,n)=>{const s=T(r,t,n),c=m(t),l=i.some((t=>m(t)===c));l&&s?(0,v.cu)(s,{left:`${t.left}%`,top:`${t.top}%`,width:`${t.width}%`,height:`${t.height}%`,transitionDuration:`${o}ms`}):l||s||r.appendChild(g(e,t,n,o,(e=>{a({event:e,item:t,index:n})})))})),i.forEach(((t,e)=>{const i=T(r,t,e),o=m(t),a=!n.some((t=>m(t)===o));i&&a&&i.parentNode.removeChild(i)}))})(t.videojs,r,i,o,a,N);else{const e=i.map(((t,e)=>g(r,t,e,a,(n=>{N({event:n,item:t,index:e})}))));b(t.videojs,(0,v.n)("div",{class:u.Fg},e))}}function M(){j()&&((t,e)=>{const n=x(t);if(!n)return;const{videoHeight:i,videoWidth:o}=e,a=o/i,r=a*e.clientHeight;n.style.width=`${e.clientWidth<r?"100%":r}px`,n.style.height=e.clientWidth<r?e.clientWidth/a+"px":"100%"})(t.videojs,t.videoElement)}!function(){if(a=a||t.videojs.currentSource(),j()){t.videojs.el().classList.add("interaction-areas"),t.videojs.one(k.f.PLAY,(()=>{"object"==typeof t.videojs.ima?t.on("adsready",(()=>{t.videojs.ima.addEventListener(window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,S)})):S()}));const e=c()(M,100);t.videojs.on(k.f.FULL_SCREEN_CHANGE,(()=>{setTimeout(e,100)}));const n=(0,v.q2)(window,"resize",M,!1);t.videojs.on(k.f.DISPOSE,n)}t.videojs.on(k.f.ENDED,(()=>{l()})),t.videojs.on(k.f.ERROR,(()=>{t.pause()}))}()}},8812:(t,e,n)=>{var i=n(2140),o=/^\s+/;t.exports=function(t){return t?t.slice(0,i(t)+1).replace(o,""):t}},2140:t=>{var e=/\s/;t.exports=function(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}},6177:(t,e,n)=>{var i=n(8953),o=n(3664),a=n(5378),r=Math.max,s=Math.min;t.exports=function(t,e,n){var c,l,d,u,v,p,h=0,f=!1,m=!1,g=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function y(e){var n=c,i=l;return c=l=void 0,h=e,u=t.apply(i,n)}function b(t){var n=t-p;return void 0===p||n>=e||n<0||m&&t-h>=d}function T(){var t=o();if(b(t))return $(t);v=setTimeout(T,function(t){var n=e-(t-p);return m?s(n,d-(t-h)):n}(t))}function $(t){return v=void 0,g&&c?y(t):(c=l=void 0,u)}function x(){var t=o(),n=b(t);if(c=arguments,l=this,p=t,n){if(void 0===v)return function(t){return h=t,v=setTimeout(T,e),f?y(t):u}(p);if(m)return clearTimeout(v),v=setTimeout(T,e),y(p)}return void 0===v&&(v=setTimeout(T,e)),u}return e=a(e)||0,i(n)&&(f=!!n.leading,d=(m="maxWait"in n)?r(a(n.maxWait)||0,e):d,g="trailing"in n?!!n.trailing:g),x.cancel=function(){void 0!==v&&clearTimeout(v),h=0,c=p=l=v=void 0},x.flush=function(){return void 0===v?u:$(o())},x}},5114:t=>{t.exports=function(){}},3664:(t,e,n)=>{var i=n(1433);t.exports=function(){return i.Date.now()}},2858:(t,e,n)=>{var i=n(6177),o=n(8953);t.exports=function(t,e,n){var a=!0,r=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return o(n)&&(a="leading"in n?!!n.leading:a,r="trailing"in n?!!n.trailing:r),i(t,e,{leading:a,maxWait:e,trailing:r})}},5378:(t,e,n)=>{var i=n(8812),o=n(8953),a=n(5414),r=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=parseInt;t.exports=function(t){if("number"==typeof t)return t;if(a(t))return NaN;if(o(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=o(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=i(t);var n=s.test(t);return n||c.test(t)?l(t.slice(2),n?2:8):r.test(t)?NaN:+t}}}]);
//# sourceMappingURL=interaction-areas.light.min.js.map