×
Create a new article
Write your page title here:
We currently have 302 articles on Knights of the Olde Speech. Type your article name above or click on one of the titles below and start writing!



Knights of the Olde Speech

MediaWiki:MusicPlayer.js: Difference between revisions

No edit summary
No edit summary
Line 44: Line 44:
           }
           }
         });
         });
        player.style.display = "none";
         //document.getElementById('EmulatorFrame').style.display = "none";
         //document.getElementById('EmulatorFrame').style.display = "none";
       }
       }

Revision as of 13:00, 10 June 2020

//Emulator iframe with one of my videos as the default src
//Meant to be used with [Template:MusicPlayer] for stories
document.getElementsByTagName('body')[0].onload = function() {
    if (document.getElementById('musicPlayerAllow') !== null) {
        var rail = document.getElementById('WikiaRail');
        var node = document.createElement("div");
        var textnode = document.createTextNode("Loading iframe...");
        node.appendChild(textnode);
        node.id = "EmulatorFrame";
        node.classList.add("EmulatorFrame");
        node.classList.add("rail-module");
       /* node.style.border = 0;
        node.style.frameborder = 0;
        node.style.height = 120;
        node.style.scrolling = 'no';
        node.src = 'https://www.youtube.com/embed/BHfqz68xEY8?version=3&enablejsapi=1';
        node.style.width = 160;
        node.style.position = "relative";
        node.style.display = "none";*/
        rail.insertBefore(node, document.getElementById('WikiaAdInContentPlaceHolder'));
        
        
        // 2. This code loads the IFrame Player API code asynchronously.
      var tag = document.createElement('script');

      tag.src = "https://www.youtube.com/iframe_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
    }
};

      // 3. This function creates an <iframe> (and YouTube player)
      //    after the API code downloads.
      var player;
      var playerReady = false;
      var isAllowed = false;
      function onYouTubeIframeAPIReady() {
        player = new YT.Player('EmulatorFrame', {
          height: '120',
          width: '160',
          videoId: 'BHfqz68xEY8',
          events: {
            'onReady': onPlayerReady
          }
        });
        player.style.display = "none";
        //document.getElementById('EmulatorFrame').style.display = "none";
      }
      

function onPlayerReady(event) {
        playerReady = true;
      }
      




function allowMusic() {
    //document.getElementById('EmulatorFrame').style.display = 'block';
    isAllowed = !isAllowed;
    if (playerReady) player.playVideo();
}

var mpa = document.getElementById('musicPlayerAllow');
mpa.setAttribute('onclick', 'allowMusic()');