Youtube Videos Not Playing in Custom Theme

Youtube Videos Not Playing in Custom Theme

dahliaa
New Member
9 0 0

Hi!

I recently inherited a customized Shopify store and need to resolve a Youtube playability issue. I'm still relatively new to javascript but see below for the code as well as the error populating the dev console when the play button is pressed. Any advice is appreciated!

 */}(),f=new WeakMap;function h(t,e,n){var i=f.get(t.element)||{};e in i||(i[e]=[]),i[e].push(n),f.set(t.element,i)}function p(t,e){return(f.get(t.element)||{})[e]||[]}function v(t,e,n){var i=f.get(t.element)||{};if(!i[e])return!0;if(!n)return i[e]=[],f.set(t.element,i),!0;var o=i[e].indexOf(n);return-1!==o&&i[e].splice(o,1),f.set(t.element,i),i[e]&&0===i[e].length}var m=["autopause","autoplay","background","byline","color","controls","dnt","height","id","loop","maxheight","maxwidth","muted","playsinline","portrait","responsive","speed","texttrack","title","transparent","url","width"];function g(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return m.reduce((function(e,n){var i=t.getAttribute("data-vimeo-".concat(n));return(i||""===i)&&(e[n]=""===i?1:i),e}),e)}function y(t,e){var n=t.html;if(!e)throw new TypeError("An element must be provided");if(null!==e.getAttribute("data-vimeo-initialized"))return e.querySelector("iframe");var i=document.createElement("div");return i.innerHTML=n,e.appendChild(i.firstChild),e.setAttribute("data-vimeo-initialized","true"),e.querySelector("iframe")}function w(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return new Promise((function(i,o){if(!s(t))throw new TypeError("“".concat(t,"” is not a vimeo.com url."));var r="https://vimeo.com/api/oembed.json?url=".concat(encodeURIComponent(t));for(var a in e)e.hasOwnProperty(a)&&(r+="&".concat(a,"=").concat(encodeURIComponent(e[a])));var u="XDomainRequest"in window?new XDomainRequest:new XMLHttpRequest;u.open("GET",r,!0),u.onload=function(){if(404!==u.status)if(403!==u.status)try{var e=JSON.parse(u.responseText);if(403===e.domain_status_code)return y(e,n),void o(new Error("“".concat(t,"” is not embeddable.")));i(e)}catch(t){o(t)}else o(new Error("“".concat(t,"” is not embeddable.")));else o(new Error("“".concat(t,"” was not found.")))},u.onerror=function(){var t=u.status?" (".concat(u.status,")"):"";o(new Error("There was an error fetching the embed code from Vimeo".concat(t,".")))},u.send()}))}function b(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){return console.warn(t),{}}return t}function E(t,e,n){if(t.element.contentWindow&&t.element.contentWindow.postMessage){var i={method:e};void 0!==n&&(i.value=n);var o=parseFloat(navigator.userAgent.toLowerCase().replace(/^.*msie (\d+).*$/,"$1"));o>=8&&o<10&&(i=JSON.stringify(i)),t.element.contentWindow.postMessage(i,t.origin)}}function k(t,e){var n,i=[];if((e=b(e)).event)"error"===e.event&&p(t,e.data.method).forEach((function(n){var i=new Error(e.data.message);i.name=e.data.name,n.reject(i),v(t,e.data.method,n)})),i=p(t,"event:".concat(e.event)),n=e.data;else if(e.method){var o=function(t,e){var n=p(t,e);if(n.length<1)return!1;var i=n.shift();return v(t,e,i),i}(t,e.method);o&&(i.push(o),n=e.value)}i.forEach((function(e){try{if("function"==typeof e)return void e.call(t,n);e.resolve(n)}catch(t){}}))}var _=new WeakMap,P=new WeakMap,T=function(){function t(e){var n=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(/*! @vimeo/player v2.10.0 | (c) 2019 Vimeo | MIT License | https://github.com/vimeo/player.js */
function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),window.jQuery&&e instanceof jQuery&&(e.length>1&&window.console&&console.warn&&console.warn("A jQuery object with multiple elements was passed, using the first element."),e=e[0]),"undefined"!=typeof document&&"string"==typeof e&&(e=document.getElementById(e)),!function(t){return Boolean(t&&1===t.nodeType&&"nodeName"in t&&t.ownerDocument&&t.ownerDocument.defaultView)}(e))throw new TypeError("You must pass either a valid element or a valid id.");var o=e.ownerDocument.defaultView;if("IFRAME"!==e.nodeName){var r=e.querySelector("iframe");r&&(e=r)}if("IFRAME"===e.nodeName&&!s(e.getAttribute("src")||""))throw new Error("The player element passed isn’t a Vimeo embed.");if(_.has(e))return _.get(e);this.element=e,this.origin="*";var u=new d((function(t,r){var u=function(e){if(s(e.origin)&&n.element.contentWindow===e.source){"*"===n.origin&&(n.origin=e.origin);var i=b(e.data);if(i&&"error"===i.event&&i.data&&"ready"===i.data.method){var o=new Error(i.data.message);return o.name=i.data.name,void r(o)}var a=i&&"ready"===i.event,u=i&&"ping"===i.method;if(a||u)return n.element.setAttribute("data-ready","true"),void t();k(n,i)}};if(o.addEventListener?o.addEventListener("message",u,!1):o.attachEvent&&o.attachEvent("onmessage",u),"IFRAME"!==n.element.nodeName){var c=g(e,i);w(a(c),c,e).then((function(t){var i=y(t,e);return n.element=i,n._originalElement=e,function(t,e){var n=f.get(t);f.set(e,n),f.delete(t)}(e,i),_.set(n.element,n),t})).catch(r)}}));return P.set(this,u),_.set(this.element,this),"IFRAME"===this.element.nodeName&&E(this,"ping"),this}return function(t,e,n){e&&i(t.prototype,e)}(t,[{key:"callMethod",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new d((function(i,o){return e.ready().then((function(){h(e,t,{resolve:i,reject:o}),E(e,t,n)})).catch(o)}))}},{key:"get",value:function(t){var e=this;return new d((function(n,i){return t=r(t,"get"),e.ready().then((function(){h(e,t,{resolve:n,reject:i}),E(e,t)})).catch(i)}))}},{key:"set",value:function(t,e){var n=this;return new d((function(i,o){if(t=r(t,"set"),null==e)throw new TypeError("There must be a value to set.");return n.ready().then((function(){h(n,t,{resolve:i,reject:o}),E(n,t,e)})).catch(o)}))}},{key:"on",value:function(t,e){if(!t)throw new TypeError("You must pass an event name.");if(!e)throw new TypeError("You must pass a callback function.");if("function"!=typeof e)throw new TypeError("The callback must be a function.");0===p(this,"event:".concat(t)).length&&this.callMethod("addEventListener",t).catch((function(){})),h(this,"event:".concat(t),e)}},{key:"off",value:function(t,e){if(!t)throw new TypeError("You must pass an event name.");if(e&&"function"!=typeof e)throw new TypeError("The callback must be a function.");v(this,"event:".concat(t),e)&&this.callMethod("removeEventListener",t).catch((function(t){}))}},{key:"loadVideo",value:function(t){return this.callMethod("loadVideo",t)}},{key:"ready",value:function(){var t=P.get(this)||new d((function(t,e){e(new Error("Unknown player. Probably unloaded."))}));return d.resolve(t)}},{key:"addCuePoint",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.callMethod("addCuePoint",{time:t,data:e})}},{key:"removeCuePoint",value:function(t){return this.callMethod("removeCuePoint",t)}},{key:"enableTextTrack",value:function(t,e){if(!t)throw new TypeError("You must pass a language.");return this.callMethod("enableTextTrack",{language:t,kind:e})}},{key:"disableTextTrack",value:function(){return this.callMethod("disableTextTrack")}},{key:"pause",value:function(){return this.callMethod("pause")}},{key:"play",value:function(){return this.callMethod("play")}},{key:"unload",value:function(){return this.callMethod("unload")}},{key:"destroy",value:function(){var t=this;return new d((function(e){P.delete(t),_.delete(t.element),t._originalElement&&(_.delete(t._originalElement),t._originalElement.removeAttribute("data-vimeo-initialized")),t.element&&"IFRAME"===t.element.nodeName&&t.element.parentNode&&t.element.parentNode.removeChild(t.element),e()}))}},{key:"getAutopause",value:function(){return this.get("autopause")}},{key:"setAutopause",value:function(t){return this.set("autopause",t)}},{key:"getBuffered",value:function(){return this.get("buffered")}},{key:"getColor",value:function(){return this.get("color")}},{key:"setColor",value:function(t){return this.set("color",t)}},{key:"getCuePoints",value:function(){return this.get("cuePoints")}},{key:"getCurrentTime",value:function(){return this.get("currentTime")}},{key:"setCurrentTime",value:function(t){return this.set("currentTime",t)}},{key:"getDuration",value:function(){return this.get("duration")}},{key:"getEnded",value:function(){return this.get("ended")}},{key:"getLoop",value:function(){return this.get("loop")}},{key:"setLoop",value:function(t){return this.set("loop",t)}},{key:"setMuted",value:function(t){return this.set("muted",t)}},{key:"getMuted",value:function(){return this.get("muted")}},{key:"getPaused",value:function(){return this.get("paused")}},{key:"getPlaybackRate",value:function(){return this.get("playbackRate")}},{key:"setPlaybackRate",value:function(t){return this.set("playbackRate",t)}},{key:"getPlayed",value:function(){return this.get("played")}},{key:"getSeekable",value:function(){return this.get("seekable")}},{key:"getSeeking",value:function(){return this.get("seeking")}},{key:"getTextTracks",value:function(){return this.get("textTracks")}},{key:"getVideoEmbedCode",value:function(){return this.get("videoEmbedCode")}},{key:"getVideoId",value:function(){return this.get("videoId")}},{key:"getVideoTitle",value:function(){return this.get("videoTitle")}},{key:"getVideoWidth",value:function(){return this.get("videoWidth")}},{key:"getVideoHeight",value:function(){return this.get("videoHeight")}},{key:"getVideoUrl",value:function(){return this.get("videoUrl")}},{key:"getVolume",value:function(){return this.get("volume")}},{key:"setVolume",value:function(t){return this.set("volume",t)}}]),t}();o||(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=function(t){"console"in window&&console.error&&console.error("There was an error creating an embed: ".concat(t))};[].slice.call(t.querySelectorAll("[data-vimeo-id], [data-vimeo-url]")).forEach((function(t){try{if(null!==t.getAttribute("data-vimeo-defer"))return;var n=g(t);w(a(n),n,t).then((function(e){return y(e,t)})).catch(e)}catch(t){e(t)}}))}(),function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document;if(!window.VimeoPlayerResizeEmbeds_){window.VimeoPlayerResizeEmbeds_=!0;var e=function(e){if(s(e.origin)&&e.data&&"spacechange"===e.data.event)for(var n=t.querySelectorAll("iframe"),i=0;i<n.length;i++)if(n[i].contentWindow===e.source){n[i].parentElement.style.paddingBottom="".concat(e.data.data[0].bottom,"px");break}};window.addEventListener?window.addEventListener("message",e,!1):window.attachEvent&&window.attachEvent("onmessage",e)}}()),e.a=T}).call(this,n(0),n(2).setImmediate)},function(t,e,n){(function(t){var i=void 0!==t&&t||"undefined"!=typeof self&&self||window,o=Function.prototype.apply;function r(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new r(o.call(setTimeout,i,arguments),clearTimeout)},e.setInterval=function(){return new r(o.call(setInterval,i,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(i,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},n(3),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(0))},function(t,e,n){(function(t,e){!function(t,n){"use strict";if(!t.setImmediate){var i,o=1,r={},s=!1,a=t.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(t);u=u&&u.setTimeout?u:t,"[object process]"==={}.toString.call(t.process)?i=function(t){e.nextTick((function(){l(t)}))}:function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?function(){var e="setImmediate$"+Math.random()+"$",n=function(n){n.source===t&&"string"==typeof n.data&&0===n.data.indexOf(e)&&l(+n.data.slice(e.length))};t.addEventListener?t.addEventListener("message",n,!1):t.attachEvent("onmessage",n),i=function(n){t.postMessage(e+n,"*")}}():t.MessageChannel?function(){var t=new MessageChannel;t.port1.onmessage=function(t){l(t.data)},i=function(e){t.port2.postMessage(e)}}():a&&"onreadystatechange"in a.createElement("script")?function(){var t=a.documentElement;i=function(e){var n=a.createElement("script");n.onreadystatechange=function(){l(e),n.onreadystatechange=null,t.removeChild(n),n=null},t.appendChild(n)}}():i=function(t){setTimeout(l,0,t)},u.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n<e.length;n++)e[n]=arguments[n+1];var s={callback:t,args:e};return r[o]=s,i(o),o++},u.clearImmediate=c}function c(t){delete r[t]}function l(t){if(s)setTimeout(l,0,t);else{var e=r[t];if(e){s=!0;try{!function(t){var e=t.callback,n=t.args;switch(n.length){case 0:e();break;case 1:e(n[0]);break;case 2:e(n[0],n[1]);break;case 3:e(n[0],n[1],n[2]);break;default:e.apply(void 0,n)}}(e)}finally{c(t),s=!1}}}}}("undefined"==typeof self?void 0===t?this:t:self)}).call(this,n(0),n(4))},function(t,e){var n,i,o=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===r||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:r}catch(t){n=r}try{i="function"==typeof clearTimeout?clearTimeout:s}catch(t){i=s}}();var u,c=[],l=!1,d=-1;function f(){l&&u&&(l=!1,u.length?c=u.concat(c):d=-1,c.length&&h())}function h(){if(!l){var t=a(f);l=!0;for(var e=c.length;e;){for(u=c,c=[];++d<e;)u&&u[d].run();d=-1,e=c.length}u=null,l=!1,function(t){if(i===clearTimeout)return clearTimeout(t);if((i===s||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(t);try{i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function v(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new p(t,e)),1!==c.length||l||a(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=v,o.addListener=v,o.once=v,o.off=v,o.removeListener=v,o.removeAllListeners=v,o.emit=v,o.prependListener=v,o.prependOnceListener=v,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e,n){"use strict";function i(t,e){Object.keys(t).some((function(n,i){return e(t[n],n,i)}))}n.r(e);var o=function(){function t(t,e){this.Splide=t,this.Components=e,this.players=[]}var e=t.prototype;return e.createPlayers=function(t,e){var n=this;this.Components.Elements.getSlides(!0).forEach((function(o){n.Components.Grid&&i(o.slide.querySelectorAll("."+n.Components.Grid.colClass),(function(i){n.createPlayer(i,t,e)})),n.createPlayer(o.slide,t,e)}))},e.createPlayer=function(t,e,n){t.getAttribute(n)&&this.players.push(new e(this.Splide,this.Components,t))},e.destroy=function(){this.players.forEach((function(t){t.destroy()}))},t}(),r=function(t,e){function n(t){return document.createElement(t)}function i(t){var e=t.parentElement;e&&e.removeChild(t)}return{init:function(){this.initElements(),this.toggleWrapper(!1),this.togglePlayButton(!1)},initElements:function(){var i=function(e){return function(t,e){return Object.keys(t.children).map((function(e){return t.children[e]})).filter((function(t){return t.classList.contains(e)}))[0]||null}(e,t.classes.container.split(" ")[0]||"")}(e);this.parent=i||e,this.className=t.classes[i?"container":"slide"].split(" ")[0]+"--has-video",this.parent.classList.add(this.className),this.wrapper=n("div"),this.iframe=n("div"),this.playButton=n("button"),this.wrapper.classList.add("splide__video"),this.playButton.classList.add("splide__video__play"),this.wrapper.appendChild(this.iframe),this.parent.appendChild(this.wrapper),this.parent.appendChild(this.playButton)},destroy:function(){this.parent.classList.remove(this.className),i(this.wrapper),i(this.playButton)},togglePlayButton:function(t){this.playButton.style.display=t?"flex":"none"},toggleWrapper:function(t){this.wrapper.style.display=t?"block":"none"},hide:function(){this.togglePlayButton(!1),this.toggleWrapper(!0)},show:function(){this.togglePlayButton(!0),this.toggleWrapper(!1)}}},s=function(t){var e=t;return{set:function(t){e=t},is:function(){for(var t=0;t<arguments.length;t++)if((t<0||arguments.length<=t?void 0:arguments[t])===e)return!0;return!1}}},a=function(){function t(t,e,n){this.Splide=t,this.Components=e,this.slide=n,this.player=null,this.elements=null,this.state=new s(1),this.videoId=this.findVideoId(),this.videoId&&(this.init(),this.bind(),this.handleClick())}var e=t.prototype;return e.init=function(){this.elements=new r(this.Splide,this.slide),this.elements.init(),this.toggleRootClass(!0),this.elements.togglePlayButton(!this.Splide.options.video.disableOverlayUI),this.isAutoplay()&&this.isActive()&&this.play()},e.setup=function(){var t=this;this.state.set(2),this.player=this.createPlayer((function(){var e=t.state.is(3);t.state.set(4),e&&t.play()}))},e.bind=function(){var t=this;this.Splide.on("active",(function(e){t.isAutoplay()&&(e.slide===t.slide?t.play():t.pause())})).on("move",(function(){t.pause()})).on("video:click",(function(e){e.slide!==t.slide&&t.pause()}))},e.handleClick=function(){var t=this;this.slide.addEventListener("mousedown",this.onMouseDown.bind(this)),this.slide.addEventListener("touchstart",this.onMouseDown.bind(this)),this.slide.addEventListener("mouseup",this.onMouseUp.bind(this)),this.slide.addEventListener("touchend",this.onMouseUp.bind(this)),this.Splide.on("drag",(function(){t.shouldHandleClick=!1}))},e.createPlayer=function(t){return void 0===t&&(t=null),null},e.play=function(){var t=this;this.state.is(1)&&this.setup(),this.state.is(7,3)||(setTimeout((function(){t.elements.hide()})),this.state.is(2)?this.state.set(3):(this.state.is(6)||this.playVideo(),this.state.set(5)))},e.pause=function(){this.Splide.options.video.disableOverlayUI||this.elements.show(),this.state.is(3)?this.state.set(2):this.state.is(5)?this.state.set(6):this.state.is(7)&&(this.state.set(4),this.pauseVideo())},e.playVideo=function(){this.player.play()},e.pauseVideo=function(){this.player.pause()},e.isActive=function(){return this.slide.classList.contains("is-active")},e.isAutoplay=function(){return this.Splide.options.video.autoplay},e.findVideoId=function(){return""},e.toggleRootClass=function(t){this.Splide.root.classList[t?"add":"remove"](this.Splide.classes.root.split(" ")[0]+"--has-video")},e.onMouseDown=function(){this.shouldHandleClick=!0},e.onMouseUp=function(){this.shouldHandleClick&&(this.Splide.emit("video:click",this),this.play())},e.onPlay=function(){this.state.is(6)?(this.state.set(7),this.pause()):(this.Splide.emit("video:play",this),this.state.set(7))},e.onPause=function(){this.Splide.emit("video:pause",this),this.state.set(4)},e.onEnded=function(){this.Splide.emit("video:ended",this),this.state.set(4)},e.destroy=function(){this.player&&(this.player.destroy(),this.player=null),this.toggleRootClass(!1),this.elements.destroy(),this.slide.removeEventListener("mousedown",this.onMouseDown.bind(this)),this.slide.removeEventListener("touchstart",this.onMouseDown.bind(this)),this.slide.removeEventListener("mouseup",this.onMouseUp.bind(this)),this.slide.removeEventListener("touchend",this.onMouseUp.bind(this))},t}(),u=["autoplay","autoPictureInPicture","controls","controlslist","crossorigin","currentTime","disablePictureInPicture","disableRemotePlayback","height","intrinsicsize","loop","muted","playsinline","poster","preload","width"],c=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.createPlayer=function(t){void 0===t&&(t=null);var e=this.Splide.options.video,n=e.playerOptions.htmlVideo,o=void 0===n?{}:n,r=document.createElement("video");return r.src=this.videoId,this.elements.iframe.appendChild(r),r.controls=!e.hideControls,r.loop=e.loop,r.volume=Math.max(Math.min(e.volume,1),0),r.muted=e.mute,i(o,(function(t,e){u.indexOf(e)>-1&&(r[e]=t)})),r.addEventListener("play",this.onPlay.bind(this)),r.addEventListener("pause",this.onPause.bind(this)),r.addEventListener("ended",this.onEnded.bind(this)),t&&r.addEventListener("loadeddata",t),r},n.findVideoId=function(){return this.slide.getAttribute("data-splide-html-video")},n.destroy=function(){this.player&&(this.player.pause(),this.player.removeAttribute("src"),this.player.load(),this.elements.iframe.removeChild(this.player),this.player=null),this.elements.destroy()},e}(a),l=function(t){function e(e,n){var i;return(i=t.call(this,e,n)||this).createPlayers(c,"data-splide-html-video"),i}return function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t),e}(o);function d(){return(d=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}var f=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.createPlayer=function(t){var e=this;void 0===t&&(t=null);var n=this.Splide.options.video,i=n.playerOptions.youtube,o=void 0===i?{}:i;return new YT.Player(this.elements.iframe,{videoId:this.videoId,playerVars:d({controls:n.hideControls?0:1,iv_load_policy:3,loop:n.loop,playlist:n.loop?this.videoId:"",rel:0,autoplay:!1},o),events:{onReady:function(n){e.onPlayerReady(n),t&&t()},onStateChange:this.onPlayerStateChange.bind(this)}})},n.onPlayerReady=function(t){var e=t.target,n=this.Splide.options.video;n.mute&&e.mute(),e.setVolume(Math.max(Math.min(100*n.volume,100),0))},n.onPlayerStateChange=function(t){var e=YT.PlayerState,n=e.PLAYING,i=e.PAUSED,o=e.ENDED;switch(!0){case t.data===n:this.onPlay();break;case t.data===i:this.onPause();break;case t.data===o:this.onEnded()}},n.playVideo=function(){this.player.playVideo()},n.pauseVideo=function(){this.player.pauseVideo()},n.findVideoId=function(){var t=this.slide.getAttribute("data-splide-youtube").match(/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/);return t&&11===t[7].length?t[7]:""},e}(a),h=function(t){function e(e,n){var i;return(i=t.call(this,e,n)||this).oldCallback=void 0,i.bindAPICallback(),i.loadAPI(),i}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.loadAPI=function(){var t=window.YT;if(this.shouldLoadAPI()){var e=document.createElement("script"),n=document.getElementsByTagName("script")[0];e.src="https://www.youtube.com/player_api",n.parentNode.insertBefore(e,n)}else t&&t.loaded&&this.onReady()},n.shouldLoadAPI=function(){for(var t=document.getElementsByTagName("script"),e=0;e<t.length;e++)if("https://www.youtube.com/player_api"===t[e].getAttribute("src"))return!1;return!0},n.bindAPICallback=function(){void 0!==window.onYouTubeIframeAPIReady&&(this.oldCallback=window.onYouTubeIframeAPIReady),window.onYouTubeIframeAPIReady=this.onYouTubeIframeAPIReady.bind(this)},n.onYouTubeIframeAPIReady=function(){this.oldCallback&&this.oldCallback(),this.onReady()},n.onReady=function(){this.createPlayers(f,"data-splide-youtube")},e}(o),p=n(1);function v(){return(v=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}var m=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.createPlayer=function(t){void 0===t&&(t=null);var e=this.Splide.options.video,n=e.playerOptions.vimeo,i=void 0===n?{}:n,o=new p.a(this.elements.iframe,v({id:this.videoId,controls:!e.hideControls,loop:e.loop},i));return o.on("play",this.onPlay.bind(this)),o.on("pause",this.onPause.bind(this)),o.on("ended",this.onEnded.bind(this)),o.setVolume(Math.max(Math.min(e.volume,1),0)),o.setMuted(i.muted||e.mute),t&&o.ready().then(t),o},n.findVideoId=function(){var t=this.slide.getAttribute("data-splide-vimeo").match(/vimeo.com\/(\d+)/);return t&&t[1]?t[1]:""},n.onPlay=function(){this.state.is(6)&&!this.isActive()?(this.player.destroy(),this.elements.show(),this.state.set(1)):(this.Splide.emit("video:play",this),this.state.set(7))},e}(a),g={HtmlVideo:l,YouTube:h,Vimeo:function(t){function e(e,n){var i;return(i=t.call(this,e,n)||this).createPlayers(m,"data-splide-vimeo"),i}return function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t),e}(o)},y={autoplay:!1,disableOverlayUI:!1,hideControls:!1,loop:!1,mute:!1,volume:.2,playerOptions:{}};function w(){return(w=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}var b="is-playing";e.default=function(t,e){var n,o=[];return{mount:function(){"object"!=typeof t.options.video&&(t.options.video={}),t.options.video=w({},y,{},t.options.video),i(g,(function(n){o.push(new n(t,e))})),function(){var e=t.root.classList;t.on("video:play",(function(t){n=t.slide,e.add(b)})).on("video:pause video:ended",(function(t){t.slide===n&&(n=null,e.remove(b))})).on("destroy",(function(){e.remove(b)}))}()},destroy:function(){o.forEach((function(t){t.destroy()}))}}}}])}}]);

 

dahliaa_0-1628536396646.png

Thanks !!

Replies 0 (0)