29 lines
1.2 KiB
JavaScript
29 lines
1.2 KiB
JavaScript
(function () {
|
|
"use strict";
|
|
|
|
var TWITCH_CHANNEL = "duda_xd";
|
|
|
|
/* ------------------------------------------------------------------
|
|
* Twitch: Live-Player einbetten. Zeigt automatisch den aktuellen
|
|
* Stream, sobald du live bist. Die Domain wird dynamisch gesetzt,
|
|
* damit der Player ueberall funktioniert (auch lokal).
|
|
* Twitch ist ein iframe-Embed -> keine CORS-Probleme.
|
|
* ------------------------------------------------------------------ */
|
|
function loadTwitch() {
|
|
var wrap = document.getElementById("twitch-embed");
|
|
if (!wrap) return;
|
|
|
|
var domain = window.location.hostname || "localhost";
|
|
var iframe = document.createElement("iframe");
|
|
iframe.src = "https://player.twitch.tv/?channel=" + TWITCH_CHANNEL +
|
|
"&parent=" + domain + "&muted=true";
|
|
iframe.setAttribute("title", "Twitch Stream");
|
|
iframe.setAttribute("allowfullscreen", "true");
|
|
iframe.setAttribute("scrolling", "no");
|
|
iframe.setAttribute("allow", "autoplay; fullscreen");
|
|
wrap.appendChild(iframe);
|
|
}
|
|
|
|
document.addEventListener("DOMContentLoaded", loadTwitch);
|
|
})();
|