Skip to content

Commit d017ba3

Browse files
committed
Next Restricted On Empty (#82)
The play next function will not attempt to play a video if the queue is empty. It will also generate an alert if attempting to skip to the next video.
1 parent 7f0a5d0 commit d017ba3

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

js/events.js

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,36 @@ function playNext(roomnum) {
137137
socket.emit('play next', {}, function(data){
138138
var videoId = data.videoId
139139

140-
// Change the video
141-
socket.emit('change video', {
142-
room: roomnum,
143-
videoId: videoId,
144-
time: 0
145-
});
146-
});
140+
// IF queue is empty do not try to change
141+
if (videoId !== "QUEUE IS EMPTY") {
142+
// Change the video
143+
socket.emit('change video', {
144+
room: roomnum,
145+
videoId: videoId,
146+
time: 0
147+
})
148+
}
149+
else {
150+
// Notify alert
151+
$.notify({
152+
title: '<strong>Queue</strong>',
153+
icon: 'fas fa-list-alt',
154+
message: " is empty!"
155+
}, {
156+
type: 'warning',
157+
delay: 400,
158+
animate: {
159+
enter: 'animated fadeInUp',
160+
exit: 'animated fadeOutRight'
161+
},
162+
placement: {
163+
from: "bottom",
164+
align: "right"
165+
},
166+
offset: 20,
167+
spacing: 10,
168+
z_index: 1031,
169+
});
170+
}
171+
})
147172
}

js/host.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function disconnected() {
7070
icon: 'fas fa-users',
7171
message: " You are now out of sync of the host"
7272
}, {
73-
type: 'warning',
73+
type: 'danger',
7474
delay: 400,
7575
animate: {
7676
enter: 'animated fadeInUp',

server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ io.sockets.on('connection', function(socket) {
101101
});
102102

103103
socket.on('play next', function(data, callback) {
104-
var videoId = ""
104+
var videoId = "QUEUE IS EMPTY"
105105

106106
switch (io.sockets.adapter.rooms['room-' + socket.roomnum].currPlayer) {
107107
case 0:
@@ -123,6 +123,7 @@ io.sockets.on('connection', function(socket) {
123123
default:
124124
console.log("Error invalid player id")
125125
}
126+
// console.log(videoId)
126127
// Remove video from the front end
127128
updateQueueVideos()
128129
callback({

0 commit comments

Comments
 (0)