UNPKG

cloudinary-video-player

Version:
6 lines 9.99 kB
/*! * Cloudinary Video Player v4.0.3 * Built on 2026-06-07T12:23:47.824Z * https://github.com/cloudinary/cloudinary-video-player */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["cloudinary-video-player"]=t():e["cloudinary-video-player"]=t()}(self,()=>(()=>{"use strict";var e,t,r={4963(e,t,r){r.r(t),r.d(t,{default:()=>p,player:()=>d,players:()=>u,videoPlayer:()=>s,videoPlayers:()=>c});var n=r(9606);const o=(e,t,r,n)=>[...document.querySelectorAll(e)].map(e=>n(e,t,r)),a=e=>{let t=null,r=!1;const n=[],o=e.then(e=>(t=e,n.forEach(e=>{let{method:r,args:n,resolve:o,reject:a}=e;try{o(t[r](...n))}catch(e){a(e)}}),n.length=0,e)).catch(e=>{throw r=!0,n.forEach(t=>{let{reject:r}=t;return r(e)}),n.length=0,e}),a=new Proxy({},{get(e,i){if("then"===i||"catch"===i||"finally"===i)return o[i].bind(o);if(i!==Symbol.toPrimitive&&i!==Symbol.toStringTag){if(t){const e=t[i];return"function"==typeof e?e.bind(t):e}if(!r)return function(){const e={},t=new Promise((t,r)=>{e.resolve=t,e.reject=r});for(var r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];return n.push({method:i,args:o,...e}),t.catch(e=>console.error("[Cloudinary] Deferred player call failed:",e)),a}}},has:(e,r)=>!t||r in t});return a},i=()=>Promise.all([r.e(869),r.e(149),r.e(76)]).then(r.bind(r,6801)),l=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Object.assign({},...t,{_internalAnalyticsMetadata:Object.assign({},...t.map(e=>e?._internalAnalyticsMetadata||{}),{playerBundle:"lazy"})})},s=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;return a(i().then(n=>n.createVideoPlayer(e,l(t),r)))},c=(e,t,r)=>o(e,t,r,s),d=function(e){return(async(e,t,o,a)=>{const i=Object.assign({},t),l=(0,n.yn)(e),s=await(async()=>{try{const{fetchAndMergeConfig:e}=await r.e(309).then(r.bind(r,4309)),t=await e(i);return Object.assign({},t,i)}catch{return i}})();if(s?.schedule?.weekly){const{shouldUseScheduleBootstrap:t,scheduleBootstrap:n}=await r.e(689).then(r.bind(r,5689));if(t(s))return n(e,s,o)}return(0,n.VB)(s)?(0,n.Lg)(e,s,o):a(l,s,o)})(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},arguments.length>2?arguments[2]:void 0,async(e,t,r)=>{const{createPlayerWithConfig:n}=await i();return n(e,l(t),r)})},u=(e,t,r)=>(async(e,t,r,n)=>{const o=document.querySelectorAll(e);return Promise.all([...o].map(e=>n(e,t,r)))})(e,t,r,d),p=(e=>{const t={...window.cloudinary||{},...e};return window.cloudinary=t,t})({videoPlayer:s,videoPlayers:c,player:d,players:u,Cloudinary:{new:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return console.warn("Cloudinary.new() is deprecated and will be removed. Please use cloudinary.videoPlayer() instead."),{videoPlayer:function(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return a(i().then(o=>o.createVideoPlayer(t,l(e,r),n)))},videoPlayers:function(t){let r=arguments.length>2?arguments[2]:void 0;return o(t,l(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),r,s)}}}}})},9606(e,t,r){r.d(t,{Lg:()=>s,VB:()=>l,Yx:()=>i,cm:()=>a,yn:()=>o});const n="cld-fluid",o=e=>{if("string"==typeof e){let t=e;0===t.indexOf("#")&&(t=t.slice(1));try{e=document.querySelector(`#${CSS.escape(t)}`)}catch{e=null}if(!e)throw new Error(`Could not find element with id ${t}`)}if(!e?.tagName)throw new Error("Must specify either an element or an element id.");if("VIDEO"!==e.tagName)throw new Error("Element is not a video tag.");return e},a=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const o=e.hasAttribute("controls");e.poster=t,e.preload="none",e.controls=!1,e.removeAttribute("controls");!1!==r.fluid&&e.classList.add(n),r.width&&e.setAttribute("width",String(r.width)),r.height&&e.setAttribute("height",String(r.height));const a=r?.sourceOptions?.aspectRatio||r?.aspectRatio;if("string"==typeof a&&a.includes(":")){const t=a.split(":").map(e=>parseInt(e.trim(),10));2===t.length&&t[0]>0&&t[1]>0&&(e.style.aspectRatio=`${t[0]} / ${t[1]}`)}return{videoElement:e,hadControls:o}},i=e=>{let{overlayRoot:t,videoElement:n,options:o,ready:a}=e;return t?.parentNode&&t.replaceWith(n),Promise.all([r.e(869),r.e(149),r.e(801)]).then(r.bind(r,6801)).then(e=>e.createVideoPlayer(n,o,a))},l=e=>!!e?.lazy,s=async(e,t,l)=>{const s=o(e),c=(e=>"string"==typeof e?.poster&&e.poster.length>0)(t)?t.poster:(await r.e(172).then(r.bind(r,4705))).getPosterUrl(t),d=(u=t.lazy)&&"object"==typeof u&&!0===u.loadOnScroll;var u;const p=!1!==t?.fluid,{hadControls:h}=a(s,c,{fluid:p,width:t?.width,height:t?.height,sourceOptions:t?.sourceOptions,aspectRatio:t?.aspectRatio}),y=((e,t)=>(e.className||"").indexOf("cld-video-player-skin-light")>-1||"light"===t?.skin)(s,t),f=document.createElement("div");f.classList.add("cld-video-player","video-js","cld-lazy-player"),p&&f.classList.add(n),f.classList.add(y?"cld-video-player-skin-light":"cld-video-player-skin-dark");const v=t?.colors;v&&(v.base&&f.style.setProperty("--color-base",v.base),v.accent&&f.style.setProperty("--color-accent",v.accent),v.text&&f.style.setProperty("--color-text",v.text)),s.parentNode.insertBefore(f,s),f.appendChild(s);const g=(()=>{const e=document.createElement("button");e.type="button",e.className="vjs-big-play-button",e.setAttribute("aria-disabled","false"),e.title="Play Video",e.setAttribute("aria-label","Play Video");const t=document.createElement("span");return t.className="vjs-icon-placeholder",t.setAttribute("aria-hidden","true"),e.appendChild(t),e})();f.appendChild(g);let m=null,b=null;const w=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(m)return m;g.removeEventListener("click",P),s.removeEventListener("click",O),b&&(b.disconnect(),b=null);const r=!0===e.autoplayFromUserGesture;h&&s.setAttribute("controls","");const n=r?e=>{e.play(),l&&l(e)}:l,o=Object.assign({},t);return delete o.lazy,m=i({overlayRoot:f,videoElement:s,options:o,ready:n}),m};function P(e){e.stopPropagation(),w({autoplayFromUserGesture:!0})}function O(){w({autoplayFromUserGesture:!0})}g.addEventListener("click",P),s.addEventListener("click",O),d&&"undefined"!=typeof IntersectionObserver&&(b=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&w({})})},{rootMargin:"0px",threshold:.25}),b.observe(s));const j={source:()=>j,loadPlayer:()=>w({autoplayFromUserGesture:!0})};return j}}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var a=n[e]={id:e,loaded:!1,exports:{}};return r[e].call(a.exports,a,a.exports,o),a.loaded=!0,a.exports}o.m=r,e=[],o.O=(t,r,n,a)=>{if(!r){var i=1/0;for(d=0;d<e.length;d++){for(var[r,n,a]=e[d],l=!0,s=0;s<r.length;s++)(!1&a||i>=a)&&Object.keys(o.O).every(e=>o.O[e](r[s]))?r.splice(s--,1):(l=!1,a<i&&(i=a));if(l){e.splice(d--,1);var c=n();void 0!==c&&(t=c)}}return t}a=a||0;for(var d=e.length;d>0&&e[d-1][2]>a;d--)e[d]=e[d-1];e[d]=[r,n,a]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce((t,r)=>(o.f[r](e,t),t),[])),o.u=e=>(({26:"adaptive-streaming",33:"playlist",40:"debug",76:"cld-player-core",172:"cld-poster-url",330:"ima",367:"dash",404:"interaction-areas",410:"recommendations-overlay",525:"shoppable",625:"chapters",691:"colors",728:"visual-search",976:"share"}[e]||e)+".min.js"),o.miniCssF=e=>{},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},o.l=(e,r,n,a)=>{if(t[e])t[e].push(r);else{var i,l;if(void 0!==n)for(var s=document.getElementsByTagName("script"),c=0;c<s.length;c++){var d=s[c];if(d.getAttribute("src")==e){i=d;break}}i||(l=!0,(i=document.createElement("script")).charset="utf-8",o.nc&&i.setAttribute("nonce",o.nc),i.src=e),t[e]=[r];var u=(r,n)=>{i.onerror=i.onload=null,clearTimeout(p);var o=t[e];if(delete t[e],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach(e=>e(n)),r)return r(n)},p=setTimeout(u.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=u.bind(null,i.onerror),i.onload=u.bind(null,i.onload),l&&document.head.appendChild(i)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),o.j=88,(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),(()=>{var e={88:0,869:0};o.f.j=(t,r)=>{var n=o.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else if(869!=t){var a=new Promise((r,o)=>n=e[t]=[r,o]);r.push(n[2]=a);var i=o.p+o.u(t),l=new Error;o.l(i,r=>{if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var a=r&&("load"===r.type?"missing":r.type),i=r&&r.target&&r.target.src;l.message="Loading chunk "+t+" failed.\n("+a+": "+i+")",l.name="ChunkLoadError",l.type=a,l.request=i,n[1](l)}},"chunk-"+t,t)}else e[t]=0},o.O.j=t=>0===e[t];var t=(t,r)=>{var n,a,[i,l,s]=r,c=0;if(i.some(t=>0!==e[t])){for(n in l)o.o(l,n)&&(o.m[n]=l[n]);if(s)var d=s(o)}for(t&&t(r);c<i.length;c++)a=i[c],o.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return o.O(d)},r=self.cloudinaryVideoPlayerChunkLoading=self.cloudinaryVideoPlayerChunkLoading||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var a=o.O(void 0,[869],()=>o(4963));return a=o.O(a)})());