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

Thanks !!