cloudinary-video-player 3.1.2-edge.3 → 3.1.2-edge.5
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/adaptive-streaming.js +18 -36920
- package/dist/adaptive-streaming.min.js +3 -4
- package/dist/chapters.js +13 -217
- package/dist/chapters.min.js +3 -4
- package/dist/cld-video-player.css +2 -4
- package/dist/cld-video-player.js +307 -46341
- package/dist/cld-video-player.light.js +307 -46341
- package/dist/cld-video-player.light.min.js +4 -5
- package/dist/cld-video-player.min.css +3 -4
- package/dist/cld-video-player.min.js +4 -5
- package/dist/colors.js +13 -67
- package/dist/colors.min.js +3 -4
- package/dist/dash.js +15 -69999
- package/dist/dash.min.js +3 -4
- package/dist/debug.js +17 -378
- package/dist/debug.min.js +3 -4
- package/dist/ima.js +24 -7049
- package/dist/ima.min.js +3 -4
- package/dist/interaction-areas.js +20 -640
- package/dist/interaction-areas.min.js +3 -4
- package/dist/node_modules_lodash_throttle_js.js +17 -395
- package/dist/playlist.js +40 -1504
- package/dist/playlist.min.js +3 -4
- package/dist/recommendations-overlay.js +19 -391
- package/dist/recommendations-overlay.min.js +3 -4
- package/dist/share.js +14 -195
- package/dist/share.min.js +3 -4
- package/dist/shoppable.js +21 -762
- package/dist/shoppable.min.js +3 -4
- package/dist/srt-text-tracks.js +13 -189
- package/dist/srt-text-tracks.min.js +3 -4
- package/dist/visual-search.js +16 -271
- package/dist/visual-search.min.js +3 -4
- package/lib/adaptive-streaming.js +1 -2
- package/lib/all.js +1 -2
- package/lib/chapters.js +1 -2
- package/lib/cld-video-player.js +1 -2
- package/lib/cld-video-player.min.css +1 -3
- package/lib/colors.js +1 -2
- package/lib/dash.js +1 -2
- package/lib/debug.js +1 -2
- package/lib/ima.js +1 -2
- package/lib/interaction-areas.js +1 -2
- package/lib/player.js +1 -2
- package/lib/playlist.js +1 -2
- package/lib/recommendations-overlay.js +1 -2
- package/lib/share.js +1 -2
- package/lib/shoppable.js +1 -2
- package/lib/srt-text-tracks.js +1 -2
- package/lib/videoPlayer.js +1 -2
- package/lib/visual-search.js +1 -2
- package/package.json +2 -3
package/dist/shoppable.min.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Cloudinary Video Player v3.1.2-edge.
|
|
3
|
-
* Built on 2025-08-
|
|
2
|
+
* Cloudinary Video Player v3.1.2-edge.5
|
|
3
|
+
* Built on 2025-08-11T13:52:35.188Z
|
|
4
4
|
* https://github.com/cloudinary/cloudinary-video-player
|
|
5
5
|
*/
|
|
6
|
-
(self.cloudinaryVideoPlayerChunkLoading=self.cloudinaryVideoPlayerChunkLoading||[]).push([[525],{9987:(t,e,s)=>{"use strict";s.d(e,{default:()=>Z});var o=s(6673),a=s.n(o);const i=function(t){const[e,s,o]=t.split(":").reverse();let a=null;return isNaN(e)||(a=60*(+o||0)*60+60*(+s||0)+ +e),a};var r=s(9339);const n={location:"right",toggleIcon:"",width:"20%",startState:"openOnPlay",autoClose:2,transformation:{quality:"auto",width:"auto",fetch_format:"auto",crop:"scale"},products:[],showPostPlayOverlay:!1},l="goto",c="seek",p="overlay",d="shoppable-panel-visible",h="shoppable-panel-hidden",u="shoppable-products-overlay",m="cld-spbl-panel",g="cld-spbl-toggle",_="cld-spbl-toggle-icon",y="cld-spbl-bar-inner",f="animate",v="cld-spbl-item",b="cld-spbl-img";var C=s(1104);const E=a().dom||a(),T=a().getComponent("Component");class N extends T{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,e),this.options_=e,this.player_=t,this.player_.on(C.f.SHOW_PRODUCTS_OVERLAY,this.renderProducts),this.dispose=()=>{this.layout_.dispose()}}renderProducts=()=>{this.player_.removeClass(d),this.player_.addClass(h),this.player_.addClass(u),this.layout_.innerHTML="";const t=this.player_.currentTime();this.options_.products.filter((e=>e.hotspots&&e.hotspots.some((e=>i(e.time)===t)))).forEach((e=>{const s=(0,r.I)(e.hotspots,(e=>i(e.time)===t)),o=E.createEl("div",{className:"cld-spbl-product-hotspot-name"},{},e.productName),a=E.createEl("div",{className:"cld-spbl-product-tooltip cld-spbl-product-tooltip-"+s.tooltipPosition},{},o),n=E.createEl("a",{className:"cld-spbl-product-hotspot accent-color-text",href:s.clickUrl,target:"_blank"},{style:"left:"+s.x+"; top:"+s.y+";"},a);this.layout_.appendChild(n)})),this.player_.one(C.f.SEEKING,this.clearLayout),this.player_.one(C.f.PLAY,this.clearLayout)};clearLayout=()=>{this.layout_.innerHTML="",this.player_.removeClass(u)};createEl(){const t=this.player_.currentDimensions();return this.layout_=E.createEl("div",{className:"cld-spbl-products-overlay",style:`padding-top: ${t.height/t.width*100}%;`}),this.layout_}}a().registerComponent("ShoppableProductsOverlay",N);const P=N,L=a().dom||a(),x=a().getComponent("ClickableComponent");class w extends x{constructor(t,e){super(t,e),this.options_=e}handleClick(t){t.preventDefault(),t.stopPropagation(),this.options_.clickHandler()}createEl(){let t={},e={};this.options_.toggleIcon?(t={className:`${_} cld-spbl-toggle-custom-icon vjs-icon-close`},e={style:`background-image: url(${this.options_.toggleIcon})`}):t={className:`${_} vjs-icon-cart`};const s=L.createEl("span",t,e),o=super.createEl("a",{className:`${g} base-color-bg`});return o.appendChild(s),this.player_.on(C.f.PRODUCT_BAR_MIN,(()=>{setTimeout((()=>{s.classList.add(f),setTimeout((()=>{s.classList.remove(f)}),1e3)}),500)})),o}}a().registerComponent("shoppablePanelToggle",w);const k=w,I=a().dom||a(),A=a().getComponent("Component");class H extends A{constructor(t,e){super(t,e),this.player_=t,this.player().addClass("cld-shoppable-panel"),this.player().addClass(h),this.contentWrpEl_=I.createEl("div",{className:"cld-spbl-bar"}),this.contentBannerEl_=I.createEl("div",{className:"cld-spbl-banner-msg base-color-text"},{},this.options_.bannerMsg||"Shop the Video"),this.contentWrpEl_.appendChild(this.contentBannerEl_);const s=new P(this.player_,this.options_);this.contentWrpEl_.appendChild(s.el_),this.contentEl_=I.createEl("div",{className:y}),this.contentWrpEl_.appendChild(this.contentEl_),this.player().el().appendChild(this.contentWrpEl_),this.addChild(new k(this.player_,{toggleIcon:this.options_.toggleIcon,clickHandler:()=>{this.togglePanel()}})),this.addChild("ShoppablePanel",this.options_),this.dispose=()=>{this.removeLayout(),super.dispose()},this.togglePanel=t=>{!0===t?(this.player().removeClass(h),this.player().addClass(d)):!1===t?(this.player().removeClass(d),this.player().addClass(h)):(this.player().toggleClass(h),this.player().toggleClass(d));let e=this.player().hasClass(d)?"productBarMax":"productBarMin";this.player().trigger(e)},"open"===this.options_.startState&&this.togglePanel(!0),this.player_.on(C.f.PLAY,(()=>{this.player_.currentTime()<.01&&("openOnPlay"===this.options_.startState&&this.togglePanel(!0,this.options_.autoClose),this.options_.autoClose&&-1!==this.options_.startState.indexOf("open")&&setTimeout((()=>{this.contentEl_.matches(":hover")?this.contentEl_.addEventListener("mouseleave",(()=>{this.togglePanel(!1)}),{once:!0}):this.togglePanel(!1)}),1e3*this.options_.autoClose))}))}createEl(){return super.createEl("div")}}a().registerComponent("shoppableBarLayout",H);const M=H;var S=s(2858),$=s.n(S),O=s(4650);const D=a().getComponent("ClickableComponent"),W=a().dom||a(),j={width:132};class B extends D{constructor(t,e){super(t,e),this.options_=e,this.isDragged=!1}handleClick(t){t.preventDefault(),t.stopPropagation(),this.el_.matches(`.dragged .${v}`)||this.options_.clickHandler(t),this.isDragged=!1}getTitle(){return this.options_.conf.title}createEl(){const t=super.createEl("a",{className:`${v} base-color-bg accent-color-text`,href:"#"});t.setAttribute("data-product-id",this.options_.conf.productId||""),t.setAttribute("data-product-name",this.options_.conf.productName||""),this.options_.conf.onHover&&R(t,this.options_.conf.onHover,this.options_.item.cloudinaryConfig()),this.options_.conf.onClick&&z(t,this.options_.conf.onClick);const e=super.createEl("img",{className:b},{src:this.options_.item.url(j)});if(t.appendChild(e),this.getTitle()){const e=W.createEl("div",{className:"cld-spbl-item-info base-color-semi-bg text-color-text"}),s=W.createEl("span",{className:"cld-spbl-item-title"},{},this.getTitle());e.appendChild(s),t.appendChild(e)}return t}}const R=(t,e,s)=>{if(t.setAttribute("data-hover-action",e.action),e.action===p){const s=W.createEl("span",{className:"cld-spbl-overlay-text base-color-text"},{},e.args),o=W.createEl("span",{className:"cld-spbl-overlay text-color-semi-bg base-color-text"},{title:e.args},s);t.appendChild(o)}else{const o=new O.A(e.args.publicId,{cloudinaryConfig:s,transformation:e.args.transformation}),a=W.createEl("img",{className:`${b} cld-spbl-hover-img`},{src:o.url(j)});t.appendChild(a)}},z=(t,e)=>{t.setAttribute("data-click-action",e.action),t.setAttribute("data-pause",e.pause),e.action===c?t.setAttribute("data-seek",e.args.time):e.action===l&&t.setAttribute("data-goto-url",e.args.url)};a().registerComponent("shoppablePanelItem",B);const U=B,V=a().getComponent("Component");class X extends V{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,e),this.options=e;const s=()=>{this.render()};t.on(C.f.SHOPPABLE_ITEM_CHANGED,s),this.render(),this.dispose=()=>{super.dispose(),t.off(C.f.SHOPPABLE_ITEM_CHANGED,s)}}createEl(){const t=super.createEl();return[m,"base-color-bg"].map((e=>t.classList.add(e))),t}removeAll(){const t=this.children();for(let e=t.length-1;e>=0;--e)this.removeChild(t[e])}getItems(){const t=this.player_.cloudinary.cloudinaryConfig();return this.options.products.map((e=>{e.onHover&&"object"==typeof e.onHover.args&&(e.onHover.args.transformation=Object.assign({},this.options.transformation,e.onHover.args.transformation));const s={productId:e.productId,productName:e.productName,title:e.title,onHover:e.onHover,onClick:e.onClick,startTime:e.startTime,endTime:e.endTime};return{imageSrc:new O.A(e.publicId,{cloudinaryConfig:t,transformation:Object.assign({},this.options.transformation,e.transformation)}),conf:s}}))}scrollToActiveItem(){const t=this.el_.getElementsByClassName("active");if(t.length>0){const e=t[0].offsetTop-12;"scrollBehavior"in document.documentElement.style?this.el_.scrollTo({top:e,behavior:"smooth"}):this.el_.scrollTop=e}}render(){this.removeAll();const t=this.getItems(),e=$()((()=>this.scrollToActiveItem()),1e3);t.forEach(((t,s)=>{const o=new U(this.player(),{item:t.imageSrc,conf:t.conf,next:1===s,current:0===s,clickHandler:t=>{let e=t.currentTarget||t.target,s=this.player_.ended()?"productClickPost":"productClick";if(this.player_.trigger(s,{productId:e.dataset.productId,productName:e.dataset.productName}),e.dataset.clickAction===l)window.open(e.dataset.gotoUrl,"_blank");else if(e.dataset.clickAction===c){const t=i(e.dataset.seek);null!==t&&(this.player_.addClass("vjs-has-started"),this.player_.postModal&&this.player_.postModal.close(),this.player_.currentTime(t),this.player_.removeClass(d),this.player_.addClass(h),this.player_.addClass(u),this.player_.one("seeked",(()=>this.player_.trigger("showProductsOverlay"))))}"false"!==e.dataset.pause&&(this.player_.pause(),i(e.dataset.pause)&&setTimeout((()=>{this.player_.play()}),1e3*i(e.dataset.pause)))}});o.on("mouseover",(t=>{let e=t.currentTarget||t.target,s=this.player_.ended()?"productHoverPost":"productHover";this.player_.trigger(s,{productId:e.dataset.productId,productName:e.dataset.productName})})),void 0!==t.conf.startTime&&void 0!==t.conf.endTime&&this.player_.on(C.f.TIME_UPDATE,(()=>{const s=this.player_.currentTime();s>=t.conf.startTime&&s<t.conf.endTime?(o.el_.classList.add("active"),e()):o.el_.classList.contains("active")&&o.el_.classList.remove("active")})),this.addChild(o)}))}}a().registerComponent("shoppablePanel",X);const G=X,Y=a().dom||a();const q=class{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.options_={...e,postPlay:!0},this.player_=t,this.render(),this.handleDragToScroll(),this.dispose=()=>{this.layout_.dispose()}}handleDragToScroll(){const t=this.player_.postModal.el_.querySelector(`.${m}`);let e=!1,s=0,o=0;t.addEventListener("mousedown",(a=>{e=!0,s=a.pageX-t.offsetLeft,o=t.scrollLeft})),document.addEventListener("mouseup",(o=>{e=!1,setTimeout((()=>{t.classList.remove("dragged")}),300);const a=o.pageX-t.offsetLeft-s;Math.abs(a)>5&&o.preventDefault()})),document.addEventListener("mousemove",(a=>{if(!e)return;a.preventDefault();const i=a.pageX-t.offsetLeft-s;t.scrollLeft=o-i,Math.abs(i)>5&&!t.classList.contains("dragged")&&t.classList.add("dragged")}))}render(){this.player_.postModal=null;const t=Y.createEl("div",{className:"cld-spbl-post-play"}),e=new G(this.player_,this.options_),s=Y.createEl("div",{className:"cld-spbl-post-title base-color-text"},{},this.options_.bannerMsg||"Shop the Video"),o=this.player_.cloudinary.currentPoster();o.transformation([o.transformation().toOptions?o.transformation().toOptions():{},{effect:"blur:3000"}]);const a=Y.createEl("div",{className:"cld-spbl-post-play-bg",style:`background-image: url("${o.url()}")`}),i=Y.createEl("button",{className:"cld-spbl-replay-btn base-color-bg vjs-icon-replay",onclick:()=>{this.player_.trigger("replay"),this.player_.postModal.close(),this.player_.play()}},{},"Replay");t.appendChild(a),t.appendChild(s),t.appendChild(e.el()),t.appendChild(i),this.player_.postModal=this.player_.createModal(t,{name:"postModal",uncloseable:!0}),this.player_.addClass("cld-spbl-post-modal"),this.player_.postModal.on("beforemodalclose",(()=>{this.player_.removeClass("cld-spbl-post-modal")}))}};const Z=class{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.options_=a().obj.merge(n,e),this.player_=t,this.options_.showPostPlayOverlay&&this.player_.on(C.f.ENDED,(()=>{this.player_.addChild(new q(this.player_,this.options_))}));const s=this.options_.width;this._injectCSS(`\n .${y} {\n transform: translateX(${s});\n }\n .${d} .vjs-control-bar {\n width: calc(100% - ${s});\n }\n .${g} {\n right: ${s};\n }\n .${m}{\n width: ${s};\n }\n `),this._setListeners()}_setListeners(){const t=this._resizeHandler.bind(this);this.player_.on(C.f.RESIZE,t),window.addEventListener("resize",t),this.dispose=()=>{this.player_.off(C.f.RESIZE,t),window.removeEventListener("resize",t),this.layout_.dispose()}}_injectCSS(t){const e=document.createElement("style");e.innerHTML=t,this.player_.el_.appendChild(e)}_resizeHandler(){const t=[["sm",0,80],["md",81,110],["lg",111,170]],e=parseFloat(this.options_.width)/100*this.player_.el_.clientWidth;let s=!1;if(e){for(const[o,a,i]of t)e>a&&e<=i&&(this.layout_.contentWrpEl_.setAttribute("size",o),s=o);s||this.layout_.contentWrpEl_.removeAttribute("size")}}init(){this.render()}render(){this.layout_=new M(this.player_,this.options_)}}},8812:(t,e,s)=>{var o=s(2140),a=/^\s+/;t.exports=function(t){return t?t.slice(0,o(t)+1).replace(a,""):t}},2140:t=>{var e=/\s/;t.exports=function(t){for(var s=t.length;s--&&e.test(t.charAt(s)););return s}},6177:(t,e,s)=>{var o=s(8953),a=s(3664),i=s(5378),r=Math.max,n=Math.min;t.exports=function(t,e,s){var l,c,p,d,h,u,m=0,g=!1,_=!1,y=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function f(e){var s=l,o=c;return l=c=void 0,m=e,d=t.apply(o,s)}function v(t){var s=t-u;return void 0===u||s>=e||s<0||_&&t-m>=p}function b(){var t=a();if(v(t))return C(t);h=setTimeout(b,function(t){var s=e-(t-u);return _?n(s,p-(t-m)):s}(t))}function C(t){return h=void 0,y&&l?f(t):(l=c=void 0,d)}function E(){var t=a(),s=v(t);if(l=arguments,c=this,u=t,s){if(void 0===h)return function(t){return m=t,h=setTimeout(b,e),g?f(t):d}(u);if(_)return clearTimeout(h),h=setTimeout(b,e),f(u)}return void 0===h&&(h=setTimeout(b,e)),d}return e=i(e)||0,o(s)&&(g=!!s.leading,p=(_="maxWait"in s)?r(i(s.maxWait)||0,e):p,y="trailing"in s?!!s.trailing:y),E.cancel=function(){void 0!==h&&clearTimeout(h),m=0,l=u=c=h=void 0},E.flush=function(){return void 0===h?d:C(a())},E}},3664:(t,e,s)=>{var o=s(1433);t.exports=function(){return o.Date.now()}},2858:(t,e,s)=>{var o=s(6177),a=s(8953);t.exports=function(t,e,s){var i=!0,r=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return a(s)&&(i="leading"in s?!!s.leading:i,r="trailing"in s?!!s.trailing:r),o(t,e,{leading:i,maxWait:e,trailing:r})}},5378:(t,e,s)=>{var o=s(8812),a=s(8953),i=s(5414),r=/^[-+]0x[0-9a-f]+$/i,n=/^0b[01]+$/i,l=/^0o[0-7]+$/i,c=parseInt;t.exports=function(t){if("number"==typeof t)return t;if(i(t))return NaN;if(a(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=a(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=o(t);var s=n.test(t);return s||l.test(t)?c(t.slice(2),s?2:8):r.test(t)?NaN:+t}}}]);
|
|
7
|
-
//# sourceMappingURL=shoppable.min.js.map
|
|
6
|
+
(self.cloudinaryVideoPlayerChunkLoading=self.cloudinaryVideoPlayerChunkLoading||[]).push([[525],{9987:(t,e,s)=>{"use strict";s.d(e,{default:()=>Z});var o=s(6673),a=s.n(o);const i=function(t){const[e,s,o]=t.split(":").reverse();let a=null;return isNaN(e)||(a=60*(+o||0)*60+60*(+s||0)+ +e),a};var r=s(9339);const n={location:"right",toggleIcon:"",width:"20%",startState:"openOnPlay",autoClose:2,transformation:{quality:"auto",width:"auto",fetch_format:"auto",crop:"scale"},products:[],showPostPlayOverlay:!1},l="goto",c="seek",p="overlay",d="shoppable-panel-visible",h="shoppable-panel-hidden",u="shoppable-products-overlay",m="cld-spbl-panel",g="cld-spbl-toggle",_="cld-spbl-toggle-icon",y="cld-spbl-bar-inner",f="animate",v="cld-spbl-item",b="cld-spbl-img";var C=s(1104);const E=a().dom||a(),T=a().getComponent("Component");class N extends T{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,e),this.options_=e,this.player_=t,this.player_.on(C.f.SHOW_PRODUCTS_OVERLAY,this.renderProducts),this.dispose=()=>{this.layout_.dispose()}}renderProducts=()=>{this.player_.removeClass(d),this.player_.addClass(h),this.player_.addClass(u),this.layout_.innerHTML="";const t=this.player_.currentTime();this.options_.products.filter((e=>e.hotspots&&e.hotspots.some((e=>i(e.time)===t)))).forEach((e=>{const s=(0,r.I)(e.hotspots,(e=>i(e.time)===t)),o=E.createEl("div",{className:"cld-spbl-product-hotspot-name"},{},e.productName),a=E.createEl("div",{className:"cld-spbl-product-tooltip cld-spbl-product-tooltip-"+s.tooltipPosition},{},o),n=E.createEl("a",{className:"cld-spbl-product-hotspot accent-color-text",href:s.clickUrl,target:"_blank"},{style:"left:"+s.x+"; top:"+s.y+";"},a);this.layout_.appendChild(n)})),this.player_.one(C.f.SEEKING,this.clearLayout),this.player_.one(C.f.PLAY,this.clearLayout)};clearLayout=()=>{this.layout_.innerHTML="",this.player_.removeClass(u)};createEl(){const t=this.player_.currentDimensions();return this.layout_=E.createEl("div",{className:"cld-spbl-products-overlay",style:`padding-top: ${t.height/t.width*100}%;`}),this.layout_}}a().registerComponent("ShoppableProductsOverlay",N);const P=N,L=a().dom||a(),x=a().getComponent("ClickableComponent");class w extends x{constructor(t,e){super(t,e),this.options_=e}handleClick(t){t.preventDefault(),t.stopPropagation(),this.options_.clickHandler()}createEl(){let t={},e={};this.options_.toggleIcon?(t={className:`${_} cld-spbl-toggle-custom-icon vjs-icon-close`},e={style:`background-image: url(${this.options_.toggleIcon})`}):t={className:`${_} vjs-icon-cart`};const s=L.createEl("span",t,e),o=super.createEl("a",{className:`${g} base-color-bg`});return o.appendChild(s),this.player_.on(C.f.PRODUCT_BAR_MIN,(()=>{setTimeout((()=>{s.classList.add(f),setTimeout((()=>{s.classList.remove(f)}),1e3)}),500)})),o}}a().registerComponent("shoppablePanelToggle",w);const k=w,I=a().dom||a(),A=a().getComponent("Component");class H extends A{constructor(t,e){super(t,e),this.player_=t,this.player().addClass("cld-shoppable-panel"),this.player().addClass(h),this.contentWrpEl_=I.createEl("div",{className:"cld-spbl-bar"}),this.contentBannerEl_=I.createEl("div",{className:"cld-spbl-banner-msg base-color-text"},{},this.options_.bannerMsg||"Shop the Video"),this.contentWrpEl_.appendChild(this.contentBannerEl_);const s=new P(this.player_,this.options_);this.contentWrpEl_.appendChild(s.el_),this.contentEl_=I.createEl("div",{className:y}),this.contentWrpEl_.appendChild(this.contentEl_),this.player().el().appendChild(this.contentWrpEl_),this.addChild(new k(this.player_,{toggleIcon:this.options_.toggleIcon,clickHandler:()=>{this.togglePanel()}})),this.addChild("ShoppablePanel",this.options_),this.dispose=()=>{this.removeLayout(),super.dispose()},this.togglePanel=t=>{!0===t?(this.player().removeClass(h),this.player().addClass(d)):!1===t?(this.player().removeClass(d),this.player().addClass(h)):(this.player().toggleClass(h),this.player().toggleClass(d));let e=this.player().hasClass(d)?"productBarMax":"productBarMin";this.player().trigger(e)},"open"===this.options_.startState&&this.togglePanel(!0),this.player_.on(C.f.PLAY,(()=>{this.player_.currentTime()<.01&&("openOnPlay"===this.options_.startState&&this.togglePanel(!0,this.options_.autoClose),this.options_.autoClose&&-1!==this.options_.startState.indexOf("open")&&setTimeout((()=>{this.contentEl_.matches(":hover")?this.contentEl_.addEventListener("mouseleave",(()=>{this.togglePanel(!1)}),{once:!0}):this.togglePanel(!1)}),1e3*this.options_.autoClose))}))}createEl(){return super.createEl("div")}}a().registerComponent("shoppableBarLayout",H);const M=H;var S=s(2858),$=s.n(S),O=s(4650);const D=a().getComponent("ClickableComponent"),W=a().dom||a(),j={width:132};class B extends D{constructor(t,e){super(t,e),this.options_=e,this.isDragged=!1}handleClick(t){t.preventDefault(),t.stopPropagation(),this.el_.matches(`.dragged .${v}`)||this.options_.clickHandler(t),this.isDragged=!1}getTitle(){return this.options_.conf.title}createEl(){const t=super.createEl("a",{className:`${v} base-color-bg accent-color-text`,href:"#"});t.setAttribute("data-product-id",this.options_.conf.productId||""),t.setAttribute("data-product-name",this.options_.conf.productName||""),this.options_.conf.onHover&&R(t,this.options_.conf.onHover,this.options_.item.cloudinaryConfig()),this.options_.conf.onClick&&z(t,this.options_.conf.onClick);const e=super.createEl("img",{className:b},{src:this.options_.item.url(j)});if(t.appendChild(e),this.getTitle()){const e=W.createEl("div",{className:"cld-spbl-item-info base-color-semi-bg text-color-text"}),s=W.createEl("span",{className:"cld-spbl-item-title"},{},this.getTitle());e.appendChild(s),t.appendChild(e)}return t}}const R=(t,e,s)=>{if(t.setAttribute("data-hover-action",e.action),e.action===p){const s=W.createEl("span",{className:"cld-spbl-overlay-text base-color-text"},{},e.args),o=W.createEl("span",{className:"cld-spbl-overlay text-color-semi-bg base-color-text"},{title:e.args},s);t.appendChild(o)}else{const o=new O.A(e.args.publicId,{cloudinaryConfig:s,transformation:e.args.transformation}),a=W.createEl("img",{className:`${b} cld-spbl-hover-img`},{src:o.url(j)});t.appendChild(a)}},z=(t,e)=>{t.setAttribute("data-click-action",e.action),t.setAttribute("data-pause",e.pause),e.action===c?t.setAttribute("data-seek",e.args.time):e.action===l&&t.setAttribute("data-goto-url",e.args.url)};a().registerComponent("shoppablePanelItem",B);const U=B,V=a().getComponent("Component");class X extends V{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,e),this.options=e;const s=()=>{this.render()};t.on(C.f.SHOPPABLE_ITEM_CHANGED,s),this.render(),this.dispose=()=>{super.dispose(),t.off(C.f.SHOPPABLE_ITEM_CHANGED,s)}}createEl(){const t=super.createEl();return[m,"base-color-bg"].map((e=>t.classList.add(e))),t}removeAll(){const t=this.children();for(let e=t.length-1;e>=0;--e)this.removeChild(t[e])}getItems(){const t=this.player_.cloudinary.cloudinaryConfig();return this.options.products.map((e=>{e.onHover&&"object"==typeof e.onHover.args&&(e.onHover.args.transformation=Object.assign({},this.options.transformation,e.onHover.args.transformation));const s={productId:e.productId,productName:e.productName,title:e.title,onHover:e.onHover,onClick:e.onClick,startTime:e.startTime,endTime:e.endTime};return{imageSrc:new O.A(e.publicId,{cloudinaryConfig:t,transformation:Object.assign({},this.options.transformation,e.transformation)}),conf:s}}))}scrollToActiveItem(){const t=this.el_.getElementsByClassName("active");if(t.length>0){const e=t[0].offsetTop-12;"scrollBehavior"in document.documentElement.style?this.el_.scrollTo({top:e,behavior:"smooth"}):this.el_.scrollTop=e}}render(){this.removeAll();const t=this.getItems(),e=$()((()=>this.scrollToActiveItem()),1e3);t.forEach(((t,s)=>{const o=new U(this.player(),{item:t.imageSrc,conf:t.conf,next:1===s,current:0===s,clickHandler:t=>{let e=t.currentTarget||t.target,s=this.player_.ended()?"productClickPost":"productClick";if(this.player_.trigger(s,{productId:e.dataset.productId,productName:e.dataset.productName}),e.dataset.clickAction===l)window.open(e.dataset.gotoUrl,"_blank");else if(e.dataset.clickAction===c){const t=i(e.dataset.seek);null!==t&&(this.player_.addClass("vjs-has-started"),this.player_.postModal&&this.player_.postModal.close(),this.player_.currentTime(t),this.player_.removeClass(d),this.player_.addClass(h),this.player_.addClass(u),this.player_.one("seeked",(()=>this.player_.trigger("showProductsOverlay"))))}"false"!==e.dataset.pause&&(this.player_.pause(),i(e.dataset.pause)&&setTimeout((()=>{this.player_.play()}),1e3*i(e.dataset.pause)))}});o.on("mouseover",(t=>{let e=t.currentTarget||t.target,s=this.player_.ended()?"productHoverPost":"productHover";this.player_.trigger(s,{productId:e.dataset.productId,productName:e.dataset.productName})})),void 0!==t.conf.startTime&&void 0!==t.conf.endTime&&this.player_.on(C.f.TIME_UPDATE,(()=>{const s=this.player_.currentTime();s>=t.conf.startTime&&s<t.conf.endTime?(o.el_.classList.add("active"),e()):o.el_.classList.contains("active")&&o.el_.classList.remove("active")})),this.addChild(o)}))}}a().registerComponent("shoppablePanel",X);const G=X,Y=a().dom||a();const q=class{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.options_={...e,postPlay:!0},this.player_=t,this.render(),this.handleDragToScroll(),this.dispose=()=>{this.layout_.dispose()}}handleDragToScroll(){const t=this.player_.postModal.el_.querySelector(`.${m}`);let e=!1,s=0,o=0;t.addEventListener("mousedown",(a=>{e=!0,s=a.pageX-t.offsetLeft,o=t.scrollLeft})),document.addEventListener("mouseup",(o=>{e=!1,setTimeout((()=>{t.classList.remove("dragged")}),300);const a=o.pageX-t.offsetLeft-s;Math.abs(a)>5&&o.preventDefault()})),document.addEventListener("mousemove",(a=>{if(!e)return;a.preventDefault();const i=a.pageX-t.offsetLeft-s;t.scrollLeft=o-i,Math.abs(i)>5&&!t.classList.contains("dragged")&&t.classList.add("dragged")}))}render(){this.player_.postModal=null;const t=Y.createEl("div",{className:"cld-spbl-post-play"}),e=new G(this.player_,this.options_),s=Y.createEl("div",{className:"cld-spbl-post-title base-color-text"},{},this.options_.bannerMsg||"Shop the Video"),o=this.player_.cloudinary.currentPoster();o.transformation([o.transformation().toOptions?o.transformation().toOptions():{},{effect:"blur:3000"}]);const a=Y.createEl("div",{className:"cld-spbl-post-play-bg",style:`background-image: url("${o.url()}")`}),i=Y.createEl("button",{className:"cld-spbl-replay-btn base-color-bg vjs-icon-replay",onclick:()=>{this.player_.trigger("replay"),this.player_.postModal.close(),this.player_.play()}},{},"Replay");t.appendChild(a),t.appendChild(s),t.appendChild(e.el()),t.appendChild(i),this.player_.postModal=this.player_.createModal(t,{name:"postModal",uncloseable:!0}),this.player_.addClass("cld-spbl-post-modal"),this.player_.postModal.on("beforemodalclose",(()=>{this.player_.removeClass("cld-spbl-post-modal")}))}};const Z=class{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.options_=a().obj.merge(n,e),this.player_=t,this.options_.showPostPlayOverlay&&this.player_.on(C.f.ENDED,(()=>{this.player_.addChild(new q(this.player_,this.options_))}));const s=this.options_.width;this._injectCSS(`\n .${y} {\n transform: translateX(${s});\n }\n .${d} .vjs-control-bar {\n width: calc(100% - ${s});\n }\n .${g} {\n right: ${s};\n }\n .${m}{\n width: ${s};\n }\n `),this._setListeners()}_setListeners(){const t=this._resizeHandler.bind(this);this.player_.on(C.f.RESIZE,t),window.addEventListener("resize",t),this.dispose=()=>{this.player_.off(C.f.RESIZE,t),window.removeEventListener("resize",t),this.layout_.dispose()}}_injectCSS(t){const e=document.createElement("style");e.innerHTML=t,this.player_.el_.appendChild(e)}_resizeHandler(){const t=[["sm",0,80],["md",81,110],["lg",111,170]],e=parseFloat(this.options_.width)/100*this.player_.el_.clientWidth;let s=!1;if(e){for(const[o,a,i]of t)e>a&&e<=i&&(this.layout_.contentWrpEl_.setAttribute("size",o),s=o);s||this.layout_.contentWrpEl_.removeAttribute("size")}}init(){this.render()}render(){this.layout_=new M(this.player_,this.options_)}}},8812:(t,e,s)=>{var o=s(2140),a=/^\s+/;t.exports=function(t){return t?t.slice(0,o(t)+1).replace(a,""):t}},2140:t=>{var e=/\s/;t.exports=function(t){for(var s=t.length;s--&&e.test(t.charAt(s)););return s}},6177:(t,e,s)=>{var o=s(8953),a=s(3664),i=s(5378),r=Math.max,n=Math.min;t.exports=function(t,e,s){var l,c,p,d,h,u,m=0,g=!1,_=!1,y=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function f(e){var s=l,o=c;return l=c=void 0,m=e,d=t.apply(o,s)}function v(t){var s=t-u;return void 0===u||s>=e||s<0||_&&t-m>=p}function b(){var t=a();if(v(t))return C(t);h=setTimeout(b,function(t){var s=e-(t-u);return _?n(s,p-(t-m)):s}(t))}function C(t){return h=void 0,y&&l?f(t):(l=c=void 0,d)}function E(){var t=a(),s=v(t);if(l=arguments,c=this,u=t,s){if(void 0===h)return function(t){return m=t,h=setTimeout(b,e),g?f(t):d}(u);if(_)return clearTimeout(h),h=setTimeout(b,e),f(u)}return void 0===h&&(h=setTimeout(b,e)),d}return e=i(e)||0,o(s)&&(g=!!s.leading,p=(_="maxWait"in s)?r(i(s.maxWait)||0,e):p,y="trailing"in s?!!s.trailing:y),E.cancel=function(){void 0!==h&&clearTimeout(h),m=0,l=u=c=h=void 0},E.flush=function(){return void 0===h?d:C(a())},E}},3664:(t,e,s)=>{var o=s(1433);t.exports=function(){return o.Date.now()}},2858:(t,e,s)=>{var o=s(6177),a=s(8953);t.exports=function(t,e,s){var i=!0,r=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return a(s)&&(i="leading"in s?!!s.leading:i,r="trailing"in s?!!s.trailing:r),o(t,e,{leading:i,maxWait:e,trailing:r})}},5378:(t,e,s)=>{var o=s(8812),a=s(8953),i=s(5414),r=/^[-+]0x[0-9a-f]+$/i,n=/^0b[01]+$/i,l=/^0o[0-7]+$/i,c=parseInt;t.exports=function(t){if("number"==typeof t)return t;if(i(t))return NaN;if(a(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=a(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=o(t);var s=n.test(t);return s||l.test(t)?c(t.slice(2),s?2:8):r.test(t)?NaN:+t}}}]);
|
package/dist/srt-text-tracks.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Cloudinary Video Player v3.1.2-edge.
|
|
3
|
-
* Built on 2025-08-
|
|
2
|
+
* Cloudinary Video Player v3.1.2-edge.5
|
|
3
|
+
* Built on 2025-08-11T13:52:54.173Z
|
|
4
4
|
* https://github.com/cloudinary/cloudinary-video-player
|
|
5
5
|
*/
|
|
6
6
|
"use strict";
|
|
7
|
+
/*
|
|
8
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
9
|
+
* This devtool is neither made for production nor for readable output files.
|
|
10
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
11
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
12
|
+
* or disable the default devtool with "devtool: false".
|
|
13
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
14
|
+
*/
|
|
7
15
|
(self["cloudinaryVideoPlayerChunkLoading"] = self["cloudinaryVideoPlayerChunkLoading"] || []).push([["srt-text-tracks"],{
|
|
8
16
|
|
|
9
17
|
/***/ "./plugins/srt-text-tracks/srt-text-tracks.js":
|
|
@@ -12,61 +20,7 @@
|
|
|
12
20
|
\****************************************************/
|
|
13
21
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
14
22
|
|
|
15
|
-
__webpack_require__.r(__webpack_exports__);
|
|
16
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
17
|
-
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
18
|
-
/* harmony export */ });
|
|
19
|
-
/* harmony import */ var srt_parser_2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! srt-parser-2 */ "../node_modules/srt-parser-2/dist/index.js");
|
|
20
|
-
|
|
21
|
-
function srtTextTracks(config, player) {
|
|
22
|
-
// Load the SRT file and convert it to WebVTT
|
|
23
|
-
const initSRT = async () => {
|
|
24
|
-
let srtResponse;
|
|
25
|
-
if (config.src) {
|
|
26
|
-
try {
|
|
27
|
-
srtResponse = await fetch(config.src);
|
|
28
|
-
if (!srtResponse.ok) {
|
|
29
|
-
throw new Error(`Failed fetching from ${config.src} with status code ${srtResponse.status}`);
|
|
30
|
-
}
|
|
31
|
-
} catch (error) {
|
|
32
|
-
console.error(error);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (!srtResponse.ok) return;
|
|
36
|
-
const srtData = await srtResponse.text();
|
|
37
|
-
const webvttCues = srt2webvtt(srtData); // Get the array of cues
|
|
38
|
-
|
|
39
|
-
const srtTrack = player.addRemoteTextTrack({
|
|
40
|
-
kind: config.kind || 'subtitles',
|
|
41
|
-
label: config.label || 'Subtitles',
|
|
42
|
-
srclang: config.srclang,
|
|
43
|
-
default: config.default,
|
|
44
|
-
mode: config.default ? 'showing' : 'disabled'
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// Add the WebVTT data to the track
|
|
48
|
-
webvttCues.forEach(cue => {
|
|
49
|
-
if (cue) {
|
|
50
|
-
srtTrack.track.addCue(new VTTCue(cue.startTime, cue.endTime, cue.text));
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
player.one('loadedmetadata', () => {
|
|
55
|
-
initSRT();
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// SRT parser
|
|
60
|
-
const srt2webvtt = data => {
|
|
61
|
-
const SRTParser = new srt_parser_2__WEBPACK_IMPORTED_MODULE_0__["default"]();
|
|
62
|
-
const cues = SRTParser.fromSrt(data);
|
|
63
|
-
return cues.map(cue => ({
|
|
64
|
-
startTime: cue.startSeconds,
|
|
65
|
-
endTime: cue.endSeconds,
|
|
66
|
-
text: cue.text
|
|
67
|
-
}));
|
|
68
|
-
};
|
|
69
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (srtTextTracks);
|
|
23
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var srt_parser_2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! srt-parser-2 */ \"../node_modules/srt-parser-2/dist/index.js\");\n\nfunction srtTextTracks(config, player) {\n // Load the SRT file and convert it to WebVTT\n const initSRT = async () => {\n let srtResponse;\n if (config.src) {\n try {\n srtResponse = await fetch(config.src);\n if (!srtResponse.ok) {\n throw new Error(`Failed fetching from ${config.src} with status code ${srtResponse.status}`);\n }\n } catch (error) {\n console.error(error);\n }\n }\n if (!srtResponse.ok) return;\n const srtData = await srtResponse.text();\n const webvttCues = srt2webvtt(srtData); // Get the array of cues\n\n const srtTrack = player.addRemoteTextTrack({\n kind: config.kind || 'subtitles',\n label: config.label || 'Subtitles',\n srclang: config.srclang,\n default: config.default,\n mode: config.default ? 'showing' : 'disabled'\n });\n\n // Add the WebVTT data to the track\n webvttCues.forEach(cue => {\n if (cue) {\n srtTrack.track.addCue(new VTTCue(cue.startTime, cue.endTime, cue.text));\n }\n });\n };\n player.one('loadedmetadata', () => {\n initSRT();\n });\n}\n\n// SRT parser\nconst srt2webvtt = data => {\n const SRTParser = new srt_parser_2__WEBPACK_IMPORTED_MODULE_0__[\"default\"]();\n const cues = SRTParser.fromSrt(data);\n return cues.map(cue => ({\n startTime: cue.startSeconds,\n endTime: cue.endSeconds,\n text: cue.text\n }));\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (srtTextTracks);\n\n//# sourceURL=webpack://cloudinary-video-player/./plugins/srt-text-tracks/srt-text-tracks.js?");
|
|
70
24
|
|
|
71
25
|
/***/ }),
|
|
72
26
|
|
|
@@ -76,138 +30,8 @@ const srt2webvtt = data => {
|
|
|
76
30
|
\**************************************************/
|
|
77
31
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
78
32
|
|
|
79
|
-
__webpack_require__.r(__webpack_exports__);
|
|
80
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
81
|
-
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
82
|
-
/* harmony export */ });
|
|
83
|
-
class Parser {
|
|
84
|
-
seperator = ",";
|
|
85
|
-
timestampToSeconds(srtTimestamp) {
|
|
86
|
-
const [rest, millisecondsString] = srtTimestamp.split(",");
|
|
87
|
-
const milliseconds = parseInt(millisecondsString);
|
|
88
|
-
const [hours, minutes, seconds] = rest.split(":").map((x) => parseInt(x));
|
|
89
|
-
const result = milliseconds * 0.001 + seconds + 60 * minutes + 3600 * hours;
|
|
90
|
-
// fix odd JS roundings, e.g. timestamp '00:01:20,460' result is 80.46000000000001
|
|
91
|
-
return Math.round(result * 1000) / 1000;
|
|
92
|
-
}
|
|
93
|
-
;
|
|
94
|
-
correctFormat(time) {
|
|
95
|
-
// Fix the format if the format is wrong
|
|
96
|
-
// 00:00:28.9670 Become 00:00:28,967
|
|
97
|
-
// 00:00:28.967 Become 00:00:28,967
|
|
98
|
-
// 00:00:28.96 Become 00:00:28,960
|
|
99
|
-
// 00:00:28.9 Become 00:00:28,900
|
|
100
|
-
// 00:00:28,96 Become 00:00:28,960
|
|
101
|
-
// 00:00:28,9 Become 00:00:28,900
|
|
102
|
-
// 00:00:28,0 Become 00:00:28,000
|
|
103
|
-
// 00:00:28,01 Become 00:00:28,010
|
|
104
|
-
// 0:00:10,500 Become 00:00:10,500
|
|
105
|
-
let str = time.replace(".", ",");
|
|
106
|
-
var hour = null;
|
|
107
|
-
var minute = null;
|
|
108
|
-
var second = null;
|
|
109
|
-
var millisecond = null;
|
|
110
|
-
// Handle millisecond
|
|
111
|
-
var [front, ms] = str.split(",");
|
|
112
|
-
millisecond = this.fixed_str_digit(3, ms);
|
|
113
|
-
// Handle hour
|
|
114
|
-
var [a_hour, a_minute, a_second] = front.split(":");
|
|
115
|
-
hour = this.fixed_str_digit(2, a_hour, false);
|
|
116
|
-
minute = this.fixed_str_digit(2, a_minute, false);
|
|
117
|
-
second = this.fixed_str_digit(2, a_second, false);
|
|
118
|
-
return `${hour}:${minute}:${second},${millisecond}`;
|
|
119
|
-
}
|
|
120
|
-
/*
|
|
121
|
-
// make sure string is 'how_many_digit' long
|
|
122
|
-
// if str is shorter than how_many_digit, pad with 0
|
|
123
|
-
// if str is longer than how_many_digit, slice from the beginning
|
|
124
|
-
// Example:
|
|
125
|
-
|
|
126
|
-
Input: fixed_str_digit(3, '100')
|
|
127
|
-
Output: 100
|
|
128
|
-
Explain: unchanged, because "100" is 3 digit
|
|
129
|
-
|
|
130
|
-
Input: fixed_str_digit(3, '50')
|
|
131
|
-
Output: 500
|
|
132
|
-
Explain: pad end with 0
|
|
133
|
-
|
|
134
|
-
Input: fixed_str_digit(3, '50', false)
|
|
135
|
-
Output: 050
|
|
136
|
-
Explain: pad start with 0
|
|
137
|
-
|
|
138
|
-
Input: fixed_str_digit(3, '7771')
|
|
139
|
-
Output: 777
|
|
140
|
-
Explain: slice from beginning
|
|
141
|
-
*/
|
|
142
|
-
fixed_str_digit(how_many_digit, str, padEnd = true) {
|
|
143
|
-
if (str.length == how_many_digit) {
|
|
144
|
-
return str;
|
|
145
|
-
}
|
|
146
|
-
if (str.length > how_many_digit) {
|
|
147
|
-
return str.slice(0, how_many_digit);
|
|
148
|
-
}
|
|
149
|
-
if (str.length < how_many_digit) {
|
|
150
|
-
if (padEnd) {
|
|
151
|
-
return str.padEnd(how_many_digit, "0");
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
return str.padStart(how_many_digit, "0");
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
tryComma(data) {
|
|
159
|
-
data = data.replace(/\r/g, "");
|
|
160
|
-
var regex = /(\d+)\n(\d{1,2}:\d{2}:\d{2},\d{1,3}) --> (\d{1,2}:\d{2}:\d{2},\d{1,3})/g;
|
|
161
|
-
let data_array = data.split(regex);
|
|
162
|
-
data_array.shift(); // remove first '' in array
|
|
163
|
-
return data_array;
|
|
164
|
-
}
|
|
165
|
-
tryDot(data) {
|
|
166
|
-
data = data.replace(/\r/g, "");
|
|
167
|
-
var regex = /(\d+)\n(\d{1,2}:\d{2}:\d{2}\.\d{1,3}) --> (\d{1,2}:\d{2}:\d{2}\.\d{1,3})/g;
|
|
168
|
-
let data_array = data.split(regex);
|
|
169
|
-
data_array.shift(); // remove first '' in array
|
|
170
|
-
this.seperator = ".";
|
|
171
|
-
return data_array;
|
|
172
|
-
}
|
|
173
|
-
fromSrt(data) {
|
|
174
|
-
var originalData = data;
|
|
175
|
-
var data_array = this.tryComma(originalData);
|
|
176
|
-
if (data_array.length == 0) {
|
|
177
|
-
data_array = this.tryDot(originalData);
|
|
178
|
-
}
|
|
179
|
-
var items = [];
|
|
180
|
-
for (var i = 0; i < data_array.length; i += 4) {
|
|
181
|
-
const startTime = this.correctFormat(data_array[i + 1].trim());
|
|
182
|
-
const endTime = this.correctFormat(data_array[i + 2].trim());
|
|
183
|
-
var new_line = {
|
|
184
|
-
id: data_array[i].trim(),
|
|
185
|
-
startTime,
|
|
186
|
-
startSeconds: this.timestampToSeconds(startTime),
|
|
187
|
-
endTime,
|
|
188
|
-
endSeconds: this.timestampToSeconds(endTime),
|
|
189
|
-
text: data_array[i + 3].trim(),
|
|
190
|
-
};
|
|
191
|
-
items.push(new_line);
|
|
192
|
-
}
|
|
193
|
-
return items;
|
|
194
|
-
}
|
|
195
|
-
toSrt(data) {
|
|
196
|
-
var res = "";
|
|
197
|
-
const end_of_line = "\r\n";
|
|
198
|
-
for (var i = 0; i < data.length; i++) {
|
|
199
|
-
var s = data[i];
|
|
200
|
-
res += s.id + end_of_line;
|
|
201
|
-
res += s.startTime + " --> " + s.endTime + end_of_line;
|
|
202
|
-
res += s.text.replace("\n", end_of_line) + end_of_line + end_of_line;
|
|
203
|
-
}
|
|
204
|
-
return res;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Parser);
|
|
208
|
-
|
|
33
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\nclass Parser {\n seperator = \",\";\n timestampToSeconds(srtTimestamp) {\n const [rest, millisecondsString] = srtTimestamp.split(\",\");\n const milliseconds = parseInt(millisecondsString);\n const [hours, minutes, seconds] = rest.split(\":\").map((x) => parseInt(x));\n const result = milliseconds * 0.001 + seconds + 60 * minutes + 3600 * hours;\n // fix odd JS roundings, e.g. timestamp '00:01:20,460' result is 80.46000000000001\n return Math.round(result * 1000) / 1000;\n }\n ;\n correctFormat(time) {\n // Fix the format if the format is wrong\n // 00:00:28.9670 Become 00:00:28,967\n // 00:00:28.967 Become 00:00:28,967\n // 00:00:28.96 Become 00:00:28,960\n // 00:00:28.9 Become 00:00:28,900\n // 00:00:28,96 Become 00:00:28,960\n // 00:00:28,9 Become 00:00:28,900\n // 00:00:28,0 Become 00:00:28,000\n // 00:00:28,01 Become 00:00:28,010\n // 0:00:10,500 Become 00:00:10,500\n let str = time.replace(\".\", \",\");\n var hour = null;\n var minute = null;\n var second = null;\n var millisecond = null;\n // Handle millisecond\n var [front, ms] = str.split(\",\");\n millisecond = this.fixed_str_digit(3, ms);\n // Handle hour\n var [a_hour, a_minute, a_second] = front.split(\":\");\n hour = this.fixed_str_digit(2, a_hour, false);\n minute = this.fixed_str_digit(2, a_minute, false);\n second = this.fixed_str_digit(2, a_second, false);\n return `${hour}:${minute}:${second},${millisecond}`;\n }\n /*\n // make sure string is 'how_many_digit' long\n // if str is shorter than how_many_digit, pad with 0\n // if str is longer than how_many_digit, slice from the beginning\n // Example:\n \n Input: fixed_str_digit(3, '100')\n Output: 100\n Explain: unchanged, because \"100\" is 3 digit\n \n Input: fixed_str_digit(3, '50')\n Output: 500\n Explain: pad end with 0\n \n Input: fixed_str_digit(3, '50', false)\n Output: 050\n Explain: pad start with 0\n \n Input: fixed_str_digit(3, '7771')\n Output: 777\n Explain: slice from beginning\n */\n fixed_str_digit(how_many_digit, str, padEnd = true) {\n if (str.length == how_many_digit) {\n return str;\n }\n if (str.length > how_many_digit) {\n return str.slice(0, how_many_digit);\n }\n if (str.length < how_many_digit) {\n if (padEnd) {\n return str.padEnd(how_many_digit, \"0\");\n }\n else {\n return str.padStart(how_many_digit, \"0\");\n }\n }\n }\n tryComma(data) {\n data = data.replace(/\\r/g, \"\");\n var regex = /(\\d+)\\n(\\d{1,2}:\\d{2}:\\d{2},\\d{1,3}) --> (\\d{1,2}:\\d{2}:\\d{2},\\d{1,3})/g;\n let data_array = data.split(regex);\n data_array.shift(); // remove first '' in array\n return data_array;\n }\n tryDot(data) {\n data = data.replace(/\\r/g, \"\");\n var regex = /(\\d+)\\n(\\d{1,2}:\\d{2}:\\d{2}\\.\\d{1,3}) --> (\\d{1,2}:\\d{2}:\\d{2}\\.\\d{1,3})/g;\n let data_array = data.split(regex);\n data_array.shift(); // remove first '' in array\n this.seperator = \".\";\n return data_array;\n }\n fromSrt(data) {\n var originalData = data;\n var data_array = this.tryComma(originalData);\n if (data_array.length == 0) {\n data_array = this.tryDot(originalData);\n }\n var items = [];\n for (var i = 0; i < data_array.length; i += 4) {\n const startTime = this.correctFormat(data_array[i + 1].trim());\n const endTime = this.correctFormat(data_array[i + 2].trim());\n var new_line = {\n id: data_array[i].trim(),\n startTime,\n startSeconds: this.timestampToSeconds(startTime),\n endTime,\n endSeconds: this.timestampToSeconds(endTime),\n text: data_array[i + 3].trim(),\n };\n items.push(new_line);\n }\n return items;\n }\n toSrt(data) {\n var res = \"\";\n const end_of_line = \"\\r\\n\";\n for (var i = 0; i < data.length; i++) {\n var s = data[i];\n res += s.id + end_of_line;\n res += s.startTime + \" --> \" + s.endTime + end_of_line;\n res += s.text.replace(\"\\n\", end_of_line) + end_of_line + end_of_line;\n }\n return res;\n }\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Parser);\n\n\n//# sourceURL=webpack://cloudinary-video-player/../node_modules/srt-parser-2/dist/index.js?");
|
|
209
34
|
|
|
210
35
|
/***/ })
|
|
211
36
|
|
|
212
|
-
}]);
|
|
213
|
-
//# sourceMappingURL=srt-text-tracks.js.map
|
|
37
|
+
}]);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Cloudinary Video Player v3.1.2-edge.
|
|
3
|
-
* Built on 2025-08-
|
|
2
|
+
* Cloudinary Video Player v3.1.2-edge.5
|
|
3
|
+
* Built on 2025-08-11T13:52:35.188Z
|
|
4
4
|
* https://github.com/cloudinary/cloudinary-video-player
|
|
5
5
|
*/
|
|
6
|
-
"use strict";(self.cloudinaryVideoPlayerChunkLoading=self.cloudinaryVideoPlayerChunkLoading||[]).push([[6],{3565:(t,e,r)=>{r.d(e,{default:()=>d});const i=class{seperator=",";timestampToSeconds(t){const[e,r]=t.split(","),i=parseInt(r),[s,d,a]=e.split(":").map((t=>parseInt(t))),n=.001*i+a+60*d+3600*s;return Math.round(1e3*n)/1e3}correctFormat(t){let e=t.replace(".",",");var r,[i,s]=e.split(",");r=this.fixed_str_digit(3,s);var[d,a,n]=i.split(":");return`${this.fixed_str_digit(2,d,!1)}:${this.fixed_str_digit(2,a,!1)}:${this.fixed_str_digit(2,n,!1)},${r}`}fixed_str_digit(t,e,r=!0){return e.length==t?e:e.length>t?e.slice(0,t):e.length<t?r?e.padEnd(t,"0"):e.padStart(t,"0"):void 0}tryComma(t){let e=(t=t.replace(/\r/g,"")).split(/(\d+)\n(\d{1,2}:\d{2}:\d{2},\d{1,3}) --> (\d{1,2}:\d{2}:\d{2},\d{1,3})/g);return e.shift(),e}tryDot(t){let e=(t=t.replace(/\r/g,"")).split(/(\d+)\n(\d{1,2}:\d{2}:\d{2}\.\d{1,3}) --> (\d{1,2}:\d{2}:\d{2}\.\d{1,3})/g);return e.shift(),this.seperator=".",e}fromSrt(t){var e=t,r=this.tryComma(e);0==r.length&&(r=this.tryDot(e));for(var i=[],s=0;s<r.length;s+=4){const t=this.correctFormat(r[s+1].trim()),e=this.correctFormat(r[s+2].trim());var d={id:r[s].trim(),startTime:t,startSeconds:this.timestampToSeconds(t),endTime:e,endSeconds:this.timestampToSeconds(e),text:r[s+3].trim()};i.push(d)}return i}toSrt(t){var e="";const r="\r\n";for(var i=0;i<t.length;i++){var s=t[i];e+=s.id+r,e+=s.startTime+" --\x3e "+s.endTime+r,e+=s.text.replace("\n",r)+r+r}return e}};const s=t=>(new i).fromSrt(t).map((t=>({startTime:t.startSeconds,endTime:t.endSeconds,text:t.text}))),d=function(t,e){e.one("loadedmetadata",(()=>{(async()=>{let r;if(t.src)try{if(r=await fetch(t.src),!r.ok)throw new Error(`Failed fetching from ${t.src} with status code ${r.status}`)}catch(t){console.error(t)}if(!r.ok)return;const i=await r.text(),d=s(i),a=e.addRemoteTextTrack({kind:t.kind||"subtitles",label:t.label||"Subtitles",srclang:t.srclang,default:t.default,mode:t.default?"showing":"disabled"});d.forEach((t=>{t&&a.track.addCue(new VTTCue(t.startTime,t.endTime,t.text))}))})()}))}}}]);
|
|
7
|
-
//# sourceMappingURL=srt-text-tracks.min.js.map
|
|
6
|
+
"use strict";(self.cloudinaryVideoPlayerChunkLoading=self.cloudinaryVideoPlayerChunkLoading||[]).push([[6],{3565:(t,e,r)=>{r.d(e,{default:()=>d});const i=class{seperator=",";timestampToSeconds(t){const[e,r]=t.split(","),i=parseInt(r),[s,d,a]=e.split(":").map((t=>parseInt(t))),n=.001*i+a+60*d+3600*s;return Math.round(1e3*n)/1e3}correctFormat(t){let e=t.replace(".",",");var r,[i,s]=e.split(",");r=this.fixed_str_digit(3,s);var[d,a,n]=i.split(":");return`${this.fixed_str_digit(2,d,!1)}:${this.fixed_str_digit(2,a,!1)}:${this.fixed_str_digit(2,n,!1)},${r}`}fixed_str_digit(t,e,r=!0){return e.length==t?e:e.length>t?e.slice(0,t):e.length<t?r?e.padEnd(t,"0"):e.padStart(t,"0"):void 0}tryComma(t){let e=(t=t.replace(/\r/g,"")).split(/(\d+)\n(\d{1,2}:\d{2}:\d{2},\d{1,3}) --> (\d{1,2}:\d{2}:\d{2},\d{1,3})/g);return e.shift(),e}tryDot(t){let e=(t=t.replace(/\r/g,"")).split(/(\d+)\n(\d{1,2}:\d{2}:\d{2}\.\d{1,3}) --> (\d{1,2}:\d{2}:\d{2}\.\d{1,3})/g);return e.shift(),this.seperator=".",e}fromSrt(t){var e=t,r=this.tryComma(e);0==r.length&&(r=this.tryDot(e));for(var i=[],s=0;s<r.length;s+=4){const t=this.correctFormat(r[s+1].trim()),e=this.correctFormat(r[s+2].trim());var d={id:r[s].trim(),startTime:t,startSeconds:this.timestampToSeconds(t),endTime:e,endSeconds:this.timestampToSeconds(e),text:r[s+3].trim()};i.push(d)}return i}toSrt(t){var e="";const r="\r\n";for(var i=0;i<t.length;i++){var s=t[i];e+=s.id+r,e+=s.startTime+" --\x3e "+s.endTime+r,e+=s.text.replace("\n",r)+r+r}return e}};const s=t=>(new i).fromSrt(t).map((t=>({startTime:t.startSeconds,endTime:t.endSeconds,text:t.text}))),d=function(t,e){e.one("loadedmetadata",(()=>{(async()=>{let r;if(t.src)try{if(r=await fetch(t.src),!r.ok)throw new Error(`Failed fetching from ${t.src} with status code ${r.status}`)}catch(t){console.error(t)}if(!r.ok)return;const i=await r.text(),d=s(i),a=e.addRemoteTextTrack({kind:t.kind||"subtitles",label:t.label||"Subtitles",srclang:t.srclang,default:t.default,mode:t.default?"showing":"disabled"});d.forEach((t=>{t&&a.track.addCue(new VTTCue(t.startTime,t.endTime,t.text))}))})()}))}}}]);
|