diff --git a/js/player.js b/js/player.js index ce815c7..b1f66aa 100644 --- a/js/player.js +++ b/js/player.js @@ -36,7 +36,10 @@ socket.on('createDaily', function(data) { var daily = document.getElementById('dailyArea'); daily.style.display='block'; currPlayer = 1 - console.log("hey i am number 1") + + // Special call to pause youtube player + // Only have to do on youtube player as it is the default player that autoplays + player.pauseVideo(); } }); diff --git a/js/yt.js b/js/yt.js index ec9f232..7509b11 100644 --- a/js/yt.js +++ b/js/yt.js @@ -10,6 +10,9 @@ var playerStatus = -1; function onYouTubeIframeAPIReady() { player = new YT.Player('player', { + playerVars: { + autoplay: 0 + }, events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange diff --git a/server.js b/server.js index 1e2aad2..824d057 100644 --- a/server.js +++ b/server.js @@ -94,6 +94,10 @@ io.sockets.on('connection', function(socket){ io.sockets.adapter.rooms['room-'+roomnum].currPlayer = playerId console.log(io.sockets.adapter.rooms['room-'+socket.roomnum].currPlayer) + // This syncs the host whenever the player changes + host = io.sockets.adapter.rooms['room-'+socket.roomnum].host + socket.broadcast.to(host).emit('getData'); + }); // Change video player @@ -181,7 +185,7 @@ io.sockets.on('connection', function(socket){ // Sets the default values when first initializing if (init){ io.sockets.adapter.rooms['room-'+socket.roomnum].currPlayer = 0 - io.sockets.adapter.rooms['room-'+socket.roomnum].currVideo = 'M7lc1UVf-VE' + io.sockets.adapter.rooms['room-'+socket.roomnum].currVideo = '' } // Gets current video from room variable