Skip to content

Commit

Permalink
Dailymotion Event Handlers
Browse files Browse the repository at this point in the history
Added event handler functionality for dailymotion. It is still very
buggy overall.
  • Loading branch information
kyle8998 committed Feb 24, 2018
1 parent a4d103d commit 55af19b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@


<br/>
NOTE: MOBILE IS CURRENTLY BROKEN, EVENT HANDLERS IN BETA

<!----------------------------------- PLAYER AREA ----------------------------------->

Expand Down
20 changes: 20 additions & 0 deletions js/dm.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ setTimeout(function() {
console.log('api ready', e);
});

// Play Event
dailyPlayer.addEventListener('play', function(e) {
console.log('dm playing', e);
playOther(roomnum)
});

// Pause Event
dailyPlayer.addEventListener('pause', function(e) {
console.log('dm pausing', e);
pauseOther(roomnum)
});

// Seek Event
dailyPlayer.addEventListener('seeked', function(e) {
console.log('dm seeking', e);
currTime = dailyPlayer.currentTime
seekOther(roomnum, currTime)
});


dailyPlayer.addEventListener('error', function(e) {
console.log('error', e);
});
Expand Down
15 changes: 12 additions & 3 deletions js/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Created for event listeners

function playOther(roomnum) {
console.log("here!")
socket.emit('play other', {
room: roomnum
});
Expand All @@ -17,7 +16,9 @@ socket.on('justPlay', function(data) {
}
break;
case 1:
dailyPlayer.play()
if (dailyPlayer.paused) {
dailyPlayer.play();
}
break;
case 2:
vimeoPlayer.getPaused().then(function(paused) {
Expand Down Expand Up @@ -76,6 +77,10 @@ function seekOther(roomnum, currTime) {
});
}


// Weird for YouTube because there is no built in seek event
// It seeks on an buffer event
// Only syncs if off by over .1 seconds
socket.on('justSeek', function(data) {
currTime = data.time
switch (currPlayer) {
Expand All @@ -86,7 +91,11 @@ socket.on('justSeek', function(data) {
}
break;
case 1:
//TODO
var clientTime = dailyPlayer.currentTime;
if (clientTime < currTime-.1 || clientTime > currTime+.1){
dailyPlayer.seek(currTime);
}
playOther(roomnum)
break;
case 2:
vimeoPlayer.getCurrentTime().then(function(seconds) {
Expand Down
19 changes: 15 additions & 4 deletions js/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,25 @@ function changeVideoId(roomnum, id) {
//player.loadVideoById(videoId);
}

var noises = false
function loveLive(roomnum) {
var test = document.getElementById("inputVideoId").innerHTML = "sjk7DiH0JhQ";

// Only for YouTube testing
socket.emit('change video', {
room: roomnum,
videoId: 'sjk7DiH0JhQ'
});
if (!noises){
socket.emit('change video', {
room: roomnum,
videoId: 'sjk7DiH0JhQ'
});
noises = true
}
else{
socket.emit('change video', {
room: roomnum,
videoId: '97uviVyw0_o'
});
noises = false
}
}

// Get time
Expand Down

0 comments on commit 55af19b

Please sign in to comment.