Module.register("youtube", {

  defaults: {
    autoPlay: "autoplay=1"
  },

  getHeader: function(){
    return this.name;
  },

  start: function(){
    Log.info("Starting module: " + this.name)
    this.width = null;
    this.height = null;
    this.border = null;
    this.frameBorder = null;
    this.vidIdRequested = null;
    this.src = null;
    this.sendSocketNotification("LISTEN_MUSIC");
    this.loaded = false
  },

  getDom: function(){

    if (this.src !== null){
      var videoFrame = document.createElement("IFRAME");
          videoFrame.id = "youtube-video-holder"
          videoFrame.width = this.width
          videoFrame.height = this.height
          videoFrame.src = this.src
          videoFrame.border = this.frameBorder
          videoFrame.style.border = this.border
        return videoFrame;
    }else{
      var div = document.createElement("DIV");
        return div;
    }
  },

  notificationReceived: function(notification){
  
    if (notification.split(" ").includes("stop")){
      this.sendSocketNotification("STOP_MEDIA");
    }else if(notification.split(" ").includes("music")){
      console.log("========== music request ==========");
      this.sendSocketNotification("PLAY_MUSIC");
      this.show();
    }else if(notification.split(" ").includes("motivation")){
      console.log("========== motivation request ==========");
      this.sendSocketNotification("PLAY_MOTIVATION");
      this.show();
    }else if(notification.split(" ").includes("entertain")){
      console.log("========== entertainment request ==========");
      this.sendSocketNotification("PLAY_ENTERTAINMENT");
      this.show();
    }else if(notification.split(" ").includes("entertainment")){
      console.log("========== entertainment request ==========");
      this.sendSocketNotification("PLAY_ENTERTAINMENT");
      this.show();
    }
  },
  socketNotificationReceived: function(notification){
    if(notification === "MUSIC_PLAYBACK"){
      this.videoGetter("M");
    }else if(notification === "MOTIVATION_PLAYBACK"){
      this.videoGetter("O");
    }else if(notification === "ENTERTAINMENT_PLAYBACK"){
      this.videoGetter("E");
    }else if(notification === "STOP_MEDIA"){
      this.videoGetter("BLANK");
    }
  },
  getData: function(){
    this.width = "640";
    this.height = "360";
    this.vidIdRequested = this.vidIdRequested
    this.src = "https://www.youtube.com/embed/" + this.vidIdRequested + "?enablejsapi=1&" + this.defaults.autoPlay;
    this.frameBorder = "0";
    this.border = "solid 4px #37474F";

    this.updateDom();
  },

  stopData: function(){
    this.width = null;
    this.height = null;
    this.vidIdRequested = null
    this.src = null
    this.frameBorder = null;
    this.border = null;

    this.updateDom();

  },
  videoGetter: function(identifier){
    if (identifier === "M"){
      var musicVidID = ["0KSOMA3QBU0", "31crA53Dgu0", "34Na4j8AVgA", "0zGcUoRlhmw", "kOkQ4T5WO9E", "avjDmeudqbo", "sTUNQC6ep18", "JzSUgOmP66Q", "niJwjCQ-pAI", "gHeSsEaTJAg", "4NJlUribp3c"];

      var length = musicVidID.length,
          roundedRandom = Math.floor(Math.random()*(length));
          this.vidIdRequested = musicVidID[roundedRandom]
          this.getData();

    }else if(identifier === "O"){
      var motivationVidID = ["ZXsQAXx_ao0", "WxOFvpplvAM", "ZXsQAXx_ao0", "ZXsQAXx_ao0", "CPQ1budJRIQ", "ZXsQAXx_ao0", "ZXsQAXx_ao0", "ZXsQAXx_ao0", "ZXsQAXx_ao0", "ZXsQAXx_ao0"];

      var length = motivationVidID.length,
          roundedRandom = Math.floor(Math.random()*(length));
          this.vidIdRequested = motivationVidID[roundedRandom]
          this.getData();

    }else if(identifier === "E"){
      var entertainmentVidID = ["1VuMdLm0ccU", "hpigjnKl7nI", "Dd7FixvoKBw", "WPkMUU9tUqk", "N0gb9v4LI4o", "gneBUA39mnI", "Zce-QT7MGSE", "1VuMdLm0ccU",  "Dd7FixvoKBw", "WPkMUU9tUqk", "N0gb9v4LI4o", "gneBUA39mnI", "Zce-QT7MGSE"]

      var length = entertainmentVidID.length,
          roundedRandom = Math.floor(Math.random()*(length));
          this.vidIdRequested = entertainmentVidID[roundedRandom];
          this.getData();

    }else if(identifier === "BLANK"){
      this.stopData();
    }
  }
});

@@ -961,11 +961,9 @@
 n)%7B%0A
-  
 %0A
+
     
@@ -1054,24 +1054,132 @@
 OP_MEDIA%22);%0A
+    %7Delse if(notification.split(%22 %22).includes(%22stopped%22))%7B%0A      this.sendSocketNotification(%22STOP_MEDIA%22);%0A
     %7Delse if
@@ -1968,16 +1968,17 @@
  %7D%0A  %7D,%0A
+%0A
   socket
@@ -2023,16 +2023,17 @@
 ation)%7B%0A
+%0A
     if(n
@@ -2354,16 +2354,17 @@
  %7D%0A  %7D,%0A
+%0A
   getDat
@@ -2370,32 +2370,33 @@
 ta: function()%7B%0A
+%0A
     this.width =
@@ -2706,24 +2706,25 @@
 function()%7B%0A
+%0A
     this.wid
@@ -2885,22 +2885,24 @@
 eDom();%0A
-%0A
   %7D,%0A
+  %0A
   videoG
@@ -2930,16 +2930,17 @@
 ifier)%7B%0A
+%0A
     if (

fix youtube notifications to accept stopped as well