var scriptHost = ""; function getHost() { var e = document.currentScript.src.split("//"); if (e.length > 1) { var n = e[1].split("/")[0]; scriptHost = n } } getHost(); class Player { constructor(e, n, t, i, s) { this.version = e, this.instance = n, this.listenerLoaded = t, this.controlsLoaded = i, this.containerID = s, this._MSConfiguration = null } getEventsContainer() { switch (this.version) { case 1: return document.getElementById(this.containerID).getElementsByTagName("video")[0]; case 2: return this.instance.divPlayer } } play() { switch (this.version) { case 1: document.getElementById(this.containerID).getElementsByTagName("video")[0].play(); case 2: this.instance.play() } } pause() { switch (this.version) { case 1: document.getElementById(this.containerID).getElementsByTagName("video")[0].pause(); break; case 2: this.instance.pause() } } forward15secs() { switch (this.version) { case 1: document.getElementById(this.containerID).getElementsByTagName("video")[0].currentTime += 15; break; case 2: this.instance.forward15Sec() } } upward15Secs() { switch (this.version) { case 1: document.getElementById(this.containerID).getElementsByTagName("video")[0].currentTime -= 15; break; case 2: this.instance.upward15Sec() } } muteUnmute() { switch (this.version) { case 1: var e = document.getElementById(this.containerID).getElementsByTagName("video")[0]; e.volume > 0 ? e.volume = 0 : e.volume = 1; break; case 2: this.instance.muteUnmute() } } dispose() { switch (this.version) { case 1: document.getElementById(this.containerID).getElementsByTagName("video")[0].innerHTML = ""; break; case 2: this.instance.dispose() } } seekTo(e) { switch (this.version) { case 2: this.instance.seekTo(e) } } changePoster(e) { switch (this.version) { case 2: this.instance.changePoster(e) } } listenTo(e, n) { switch (this.version) { case 1: document.getElementById(this.containerID).getElementsByTagName("video")[0].addEventListener(e, e => n(e)); break; case 2: this.instance.divPlayer.addEventListener(e, e => n(e)) } } getCurrentTime() { switch (this.version) { case 1: console.error("Method getCurrentTime() not supported for player V1!"); break; case 2: return this.instance.getCurrentTime() } } } var MainStreaming = { lastContainer: null, instance: null, instances: [], clear: function () { for (var e = 0; e < this.instances.length; e++)2 == this.instances[e].version && (MSPlayer.disposePlayer(this.instances[e].instance), delete this.instances[e].instance), this.instances[e] = null; this.instances = [] }, locateByContainerID: function (e) { for (var n = 0; n < this.instances; n++)if (this.instances[n].containerID == e) return this.instances[n]; return null }, getInstance: function (e) { return this.instances[e].instance }, get: function (e) { return this.instances[e] }, last: function () { return this.instances[this.instances.length - 1] }, lastInstance: function () { return this.instances[this.instances.length - 1].instance }, embed: function (e, n) { if (console.log("[MainStreaming Loader] Starting..."), console.log("[MainStreaming Loader] Cleaning up..."), MainStreaming.clear(), console.log("[MainStreaming Loader] Fetching correct script from WT..."), console.log(n), null != n) if (null != n.containerID) { null != n.requestHost && "" != n.requestHost || (n.requestHost = scriptHost, n.msRequestHost = scriptHost), null != n.bufferLength && "" != n.bufferLength || (n.bufferLength = 300), null != n.maxBufferLength && "" != n.maxBufferLength || (n.maxBufferLength = 600), null != n.autoPlay && null != n.autoPlay && n.autoPlay && (n.startMute = !0), this.play = function () { MainStreaming.instances[n.containerID].play() }, this.pause = function () { MainStreaming.instances[n.containerID].pause() }, this.forward15secs = function () { MainStreaming.instances[n.containerID].forward15secs() }, this.upward15Secs = function () { MainStreaming.instances[n.containerID].upward15Secs() }, this.muteUnmute = function () { MainStreaming.instances[n.containerID].muteUnmute() }, this.destroy = function () { MainStreaming.instances[n.containerID].dispose() }, this.listenTo = function (e, t) { MainStreaming.instances[n.containerID].listenTo(e, t) }, this.seekTo = function (e) { MainStreaming.instances[n.containerID].seekTo(e) }, this.getCurrentTime = function () { return MainStreaming.instances[n.containerID].getCurrentTime() }, this.changePoster = function (e) { MainStreaming.instances[n.containerID].changePoster(e) }, this.instance = function () { return MainStreaming.instances[n.containerID].instance }, document.getElementById(n.containerID).innerHTML = ""; var t = null; null != n.skinId && null != n.skinId ? (console.log("Using skinID"), t = window.location.protocol + "//" + n.requestHost + "/api/v2/playerloader/content/" + e + "?skinId=" + n.skinId) : null != n.version && null != n.version ? t = window.location.protocol + "//" + n.requestHost + "/api/v2/playerloader/content/" + e + "?version=" + n.version : null != n.skinId && null != n.skinId || (t = window.location.protocol + "//" + n.requestHost + "/api/v2/playerloader/content/" + e), console.log("[MainStreaming Loader] Actual call (" + t + ")..."), player = fetch(t).then(e => e.json()).then(t => { if (200 == t.responseCode) return MainStreaming.inject(e, n, t, t.versionHash) }).catch(e => { console.error(e) }) } else console.error("[MainStreaming Loader] DomID not setted in options!"); else console.error("[MainStreaming Loader] Can't load Player without options!") }, inject: function (e, n, t, i) { console.log("[MainStreaming Loader] Injecting JS for MainStreaming Player V" + t.playerVersion + "..."), fetch(window.location.protocol + "//" + n.requestHost + "/loader/playerV" + t.playerVersion + ".js?t=" + i).then(e => e.text()).then(i => { var s = document.createElement("script"); s.innerHTML = i, document.body.appendChild(s), console.log("[MainStreaming Loader] Executing startup form MainStreaming Player V" + t.playerVersion + "..."); var a = null; switch (t.playerVersion) { case 1: a = new MainStreamingV3.embed(e, n), setTimeout(() => { var e = document.getElementById(n.containerID); if (null != e && null != e) { var t = new Player(1, a, !1, !1, n.containerID); return t._MSConfiguration = n, MainStreaming.instances[n.containerID] = t, this.triggerLoaded(n.containerID), t } }, 500); break; case 2: a = MSPlayer.Startup({ domID: n.containerID, contentID: e, playerOptions: n }).then(e => { var t = new Player(2, e, !1, !1, n.containerID); return MainStreaming.instances[n.containerID] = t, this.triggerLoaded(n.containerID), this.instance = e, t }) } }) }, triggerLoaded: function (e) { var n = new CustomEvent("loaded"); document.getElementById(e).dispatchEvent(n) } };