@@ -183,14 +183,52 @@ function idParse(videoId) {
183183 }
184184 return videoId
185185}
186- // QueueVideo
187- function enqueueVideo ( roomnum ) {
188- //var videoId = 'sjk7DiH0JhQ';
189- var videoId = document . getElementById ( "inputVideoId" ) . value ;
190- videoId = idParse ( videoId )
191186
192- if ( videoId != "invalid" ) {
193- // Actually change the video!
187+ // This parses the ID out of the video link
188+ function playlistParse ( videoId ) {
189+ // If user enters a full link
190+ if ( videoId . includes ( "https://" ) || videoId . includes ( "http://" ) || videoId . includes ( ".com/" ) ) {
191+ // Do some string processing with regex
192+ switch ( currPlayer ) {
193+ case 0 :
194+ var myRegex = / .+ & l i s t = ( [ A - Z a - z 0 - 9 \- _ ] + ) / g
195+ var match = myRegex . exec ( videoId )
196+ if ( match != null ) {
197+ return match [ 1 ]
198+ }
199+ break ;
200+
201+ case 1 :
202+ break ;
203+
204+ case 2 :
205+ break ;
206+ case 3 :
207+ break ;
208+ default :
209+ console . log ( "Error invalid player" )
210+ }
211+ }
212+ return "invalid"
213+ }
214+
215+ function enqueueVideoParse ( roomnum ) {
216+ var videoId = document . getElementById ( "inputVideoId" ) . value ;
217+ enqueueVideo ( roomnum , videoId )
218+ }
219+
220+ // QueueVideo
221+ function enqueueVideo ( roomnum , rawId ) {
222+ videoId = idParse ( rawId )
223+ playlistId = playlistParse ( rawId )
224+
225+ if ( playlistId != "invalid" ) {
226+ socket . emit ( 'enqueue playlist' , {
227+ room : roomnum ,
228+ playlistId : playlistId ,
229+ user : username
230+ } )
231+ } else if ( videoId != "invalid" ) {
194232 socket . emit ( 'enqueue video' , {
195233 room : roomnum ,
196234 videoId : videoId ,
@@ -216,11 +254,14 @@ function emptyQueue(roomnum) {
216254 } )
217255}
218256
257+ function changeVideoParse ( roomnum ) {
258+ var videoId = document . getElementById ( "inputVideoId" ) . value
259+ changeVideo ( roomnum , videoId )
260+ }
261+
219262// Change playVideo
220- function changeVideo ( roomnum ) {
221- //var videoId = 'sjk7DiH0JhQ';
222- var videoId = document . getElementById ( "inputVideoId" ) . value ;
223- videoId = idParse ( videoId )
263+ function changeVideo ( roomnum , rawId ) {
264+ var videoId = idParse ( rawId )
224265
225266 if ( videoId != "invalid" ) {
226267 var time = getTime ( )
@@ -279,7 +320,8 @@ function loveLive(roomnum) {
279320 // rookie, russian roulette, i want you back, TT, whistle, ddu du ddu du, turtle, 24/7
280321 // something new, #cookie jar, lion heart, i will show you, bubble pop, girl front, love cherry motion, ice cream cake
281322 // stay (taeyeon), ordinary love, 11:11, SObeR, I'm so sick, heaven, genie, dinosaur
282- // Travel
323+ // Travel, blow your mind, pop/stars, BBIBBI, gotta go, galaxy, my trouble, blue
324+ // love scenario, dance the night away, solo, some, yes or yes, when the wind blows, hi high, don't forget
283325 var video_roulette = [
284326 '97uviVyw0_o' , 'tIWpr3tHzII' , 'WkdtmT8A2iY' , 'U7mPqycQ0tQ' ,
285327 'i0p1bmr0EmE' , 'FzVR_fymZw4' , 'eNmL4JiGxZQ' , 'J_CFBjAyPWE' ,
@@ -291,11 +333,15 @@ function loveLive(roomnum) {
291333 'bw9CALKOvAI' , 'tyInv6RWL0Q' , 'VBbeuXW8Nko' , 'glXgSSOKlls' ,
292334 'k9_XH1YibcY' , 'xGav-z5yRiU' , 'WLJyhhNCHi0' , 'DgT4CPv_CCE' ,
293335 'F4oHuML9U2A' , 'L9ro1KjkJMg' , '6SwiSpudKWI' , '8Oz7DG76ibY' ,
294- 'xRbPAVnqtcs'
336+ 'xRbPAVnqtcs' , '08ATpBqlAIk' , 'UOxkGD8qRB4' , 'nM0xDI5R50E' ,
337+ 'HlN2BXNJzxA' , '9U8uA702xrE' , 'JRdcPhDkNYw' , 'F34e6LYro-4' ,
338+ 'vecSVX1QYbQ' , 'Fm5iP0S1z9w' , 'b73BI9eUkjM' , 'hZmoMyFXDoI' ,
339+ 'mAKsZ26SabQ' , 'o3pOzegB-7w' , '846cjX0ZTrk' , 'TcytstV1_XE'
340+
295341 ]
296342
297- // Random number between 0 and 40 inclusive
298- var random = Math . floor ( Math . random ( ) * ( 41 ) )
343+ // Random number between 0 and 56 inclusive
344+ var random = Math . floor ( Math . random ( ) * ( 56 ) )
299345 // Only for YouTube testing
300346 socket . emit ( 'change video' , {
301347 room : roomnum ,
@@ -324,7 +370,6 @@ socket.on('getData', function(data) {
324370
325371function changePlayer ( roomnum , playerId ) {
326372 if ( playerId != currPlayer ) {
327- console . log ( "I changed!" )
328373 socket . emit ( 'change player' , {
329374 room : roomnum ,
330375 playerId : playerId
@@ -336,7 +381,6 @@ function changePlayer(roomnum, playerId) {
336381function changeSinglePlayer ( playerId ) {
337382 return new Promise ( ( resolve , reject ) => {
338383 if ( playerId != currPlayer ) {
339- console . log ( "I changed!" )
340384 socket . emit ( 'change single player' , {
341385 playerId : playerId
342386 } ) ;
0 commit comments