How to use Player method in Jasmine-core

Best JavaScript code snippet using jasmine-core

jquery.mb.vimeo_player.js

Source:jquery.mb.vimeo_player.js Github

copy

Full Screen

...199 vimeo_player.controlBar.removeClass( "visible" );200 } );201 }202 jQuery( document ).on( "vimeo_api_loaded", function() {203 vimeo_player.player = new Vimeo.Player( playerID, options );204 vimeo_player.player.ready().then( function() {205 var VEvent;206 function start() {207 vimeo_player.isReady = true;208 if( vimeo_player.opt.mute )209 setTimeout( function() {210 $vimeo_player.v_mute();211 }, 1000 );212 if( vimeo_player.opt.showControls )213 jQuery.vimeo_player.buildControls( vimeo_player );214 if( vimeo_player.opt.autoPlay )215 setTimeout( function() {216 $vimeo_player.v_play();217 setTimeout( function() {...

Full Screen

Full Screen

socketGameLogic.js

Source:socketGameLogic.js Github

copy

Full Screen

1const {table, buildDeck, shuffleDeck, getHands, envidoCount} = require("./socketGameLogicConst")2const axios = require("axios");3let timeOut;4function setNewRound(playerOne, playerTwo, common, isPlayerOne, roomId, points, io, isPlayerTwo){5 if(isPlayerOne){6 playerTwo.score += points;7 playerOne.scoreRival += points;8 }9 else if(isPlayerTwo){10 playerOne.score += points;11 playerTwo.scoreRival += points;12 }13 // check if there is a winner14 if(playerOne.score >= common.scoreToWin || playerTwo.score >= common.scoreToWin){15 if(playerOne.score >= common.scoreToWin){16 io.to(playerOne.id).emit("gameEnds", ({data: table.games[roomId], winner: playerOne.name}));17 io.to(playerTwo.id).emit("gameEnds", ({data: table.games[roomId], winner: playerOne.name}));18 }19 else if(playerTwo.score >= common.scoreToWin){20 io.to(playerOne.id).emit("gameEnds", ({data: table.games[roomId], winner: playerTwo.name}));21 io.to(playerTwo.id).emit("gameEnds", ({data: table.games[roomId], winner: playerTwo.name}));22 }23 delete table.games[roomId];24 return;25 }26 //reiniciar estados de playerOne, Two y common para empezar siguiente ronda27 table.games[roomId].playerOne = {...table.games[roomId].playerOne, turnNumber: 1,28 tableRival: [],29 tablePlayer: [],30 bet: false,31 roundResults: [],}32 table.games[roomId].playerTwo = {...table.games[roomId].playerTwo, turnNumber: 1,33 tableRival: [],34 tablePlayer: [],35 bet: false,36 roundResults: [],}37 table.games[roomId].common = {...table.games[roomId].common, envidoList: [],38 trucoBet: 1,39 envidoBet: 0,40 cumulativeScore: 0,41 roundResults: [],42 turn: 1,}43 let deck = buildDeck(); //contruye deck44 deck = shuffleDeck(deck); //baraja deck45 const [playerAhand, playerBhand] = getHands(deck); //obtiene manos de 3 cartas de dos jugadores46 //manos iniciales al iniciar partida47 table.games[roomId].playerOne.hand = playerAhand;48 table.games[roomId].playerTwo.hand = playerBhand;49 //manos copias al iniciar partida50 table.games[roomId].common.playerOneHand = [...playerAhand];51 table.games[roomId].common.playerTwoHand = [...playerBhand];52 //cambiar de jugador que inicia y apuesta iniciales53 if(table.games[roomId].playerOne.starts){54 table.games[roomId].playerTwo.isTurn = true;55 table.games[roomId].playerOne.isTurn = false;56 table.games[roomId].playerOne.starts = false;57 table.games[roomId].playerTwo.starts = true;58 //dejar las apuestas al comienzo59 table.games[roomId].playerOne.betOptions = table.betsList.firstTurn;60 table.games[roomId].playerTwo.betOptions = table.betsList.firstTurn;61 }62 else{63 table.games[roomId].playerOne.isTurn = true;64 table.games[roomId].playerTwo.isTurn = false;65 table.games[roomId].playerOne.starts = true;66 table.games[roomId].playerTwo.starts = false;67 //dejar las apuestas al comienzo68 table.games[roomId].playerOne.betOptions = table.betsList.firstTurn;69 table.games[roomId].playerTwo.betOptions = table.betsList.firstTurn;70 };71}72function checkWinnerCards(number, playerOne, playerTwo, common, roomId, io){73 if(playerOne.tableRival[number] && playerTwo.tableRival[number] && common.turn === number+1){74 if(playerOne.tablePlayer[number].truco < playerTwo.tablePlayer[number].truco){75 common.roundResults.push("playerOne");76 playerOne.isTurn = true;77 playerTwo.isTurn = false;78 if(common.trucoBet > 1){79 io.to(playerOne.id).emit("bet", table.betsList.noTruco, false, true);80 io.to(playerTwo.id).emit("bet", table.betsList.noTruco, false, false);81 }82 else{83 io.to(playerOne.id).emit("bet", table.betsList.otherTurn, false, true);84 io.to(playerTwo.id).emit("bet", table.betsList.otherTurn, false, false);85 }86 // io.in(roomId).emit("messages", {msg: `Gana ${playerOne.name}!`});87 }88 else if(playerOne.tablePlayer[number].truco > playerTwo.tablePlayer[number].truco){89 common.roundResults.push("playerTwo");90 playerOne.isTurn = false;91 playerTwo.isTurn = true;92 if(common.trucoBet > 1){93 io.to(playerOne.id).emit("bet", table.betsList.noTruco, false, false);94 io.to(playerTwo.id).emit("bet", table.betsList.noTruco, false, true);95 }96 else{97 io.to(playerOne.id).emit("bet", table.betsList.otherTurn, false, false);98 io.to(playerTwo.id).emit("bet", table.betsList.otherTurn, false, true);99 }100 // io.in(roomId).emit("messages", {msg: `Gana ${playerTwo.name}!`});101 }102 else{103 common.roundResults.push("tie");104 if(playerOne.starts){105 playerOne.isTurn = true;106 playerTwo.isTurn = false;107 if(common.trucoBet > 1){108 io.to(playerOne.id).emit("bet", table.betsList.noTruco, false, true);109 io.to(playerTwo.id).emit("bet", table.betsList.noTruco, false, false);110 }111 else{112 io.to(playerOne.id).emit("bet", table.betsList.otherTurn, false, true);113 io.to(playerTwo.id).emit("bet", table.betsList.otherTurn, false, false);114 }115 }116 else{117 playerOne.isTurn = false;118 playerTwo.isTurn = true;119 if(common.trucoBet > 1){120 io.to(playerOne.id).emit("bet", table.betsList.noTruco, false, false);121 io.to(playerTwo.id).emit("bet", table.betsList.noTruco, false, true);122 }123 else{124 io.to(playerOne.id).emit("bet", table.betsList.otherTurn, false, false);125 io.to(playerTwo.id).emit("bet", table.betsList.otherTurn, false, true);126 }127 }128 // io.in(roomId).emit("messages", {msg: `Empate`});129 }130 common.turn++;131 // common.trucoBet > 1? io.in(roomId).emit("bet", table.betsList.noTruco, false) : io.in(roomId).emit("bet", table.betsList.otherTurn, false);132 }133}134function noQuieroEnvido(playerOne, playerTwo, isPlayerOne, score, io, isPlayerTwo){135 playerOne.betOptions = [];136 playerOne.bet = false;137 playerTwo.betOptions = [];138 playerTwo.bet = false;139 if(isPlayerOne){140 playerTwo.score += score;141 playerOne.scoreRival += score;142 if(playerOne.starts && !playerOne.tablePlayer[0]){143 playerOne.isTurn = true;144 playerTwo.isTurn = false;145 io.to(playerTwo.id).emit("updateScore", score, false);146 io.to(playerOne.id).emit("updateRivalScore", score, true);147 }148 else if((playerTwo.starts && !playerTwo.tablePlayer[0])){149 playerOne.isTurn = false;150 playerTwo.isTurn = true;151 io.to(playerTwo.id).emit("updateScore", score, true);152 io.to(playerOne.id).emit("updateRivalScore", score, false);153 }154 else if(playerOne.starts){155 playerOne.isTurn = false;156 playerTwo.isTurn = true;157 io.to(playerTwo.id).emit("updateScore", score, true);158 io.to(playerOne.id).emit("updateRivalScore", score, false);159 }160 else{161 playerOne.isTurn = true;162 playerTwo.isTurn = false;163 io.to(playerTwo.id).emit("updateScore", score, false);164 io.to(playerOne.id).emit("updateRivalScore", score, true);165 } 166 }167 else if(isPlayerTwo){168 playerOne.score += score;169 playerTwo.scoreRival += score;170 if(playerOne.starts && !playerOne.tablePlayer[0]){171 playerOne.isTurn = true;172 playerTwo.isTurn = false;173 io.to(playerTwo.id).emit("updateRivalScore", score, false);174 io.to(playerOne.id).emit("updateScore", score, true);175 }176 else if((playerTwo.starts && !playerTwo.tablePlayer[0])){177 playerOne.isTurn = false;178 playerTwo.isTurn = true;179 io.to(playerTwo.id).emit("updateRivalScore", score, true);180 io.to(playerOne.id).emit("updateScore", score, false);181 }182 else if(playerOne.starts){183 playerOne.isTurn = false;184 playerTwo.isTurn = true;185 io.to(playerTwo.id).emit("updateRivalScore", score, true);186 io.to(playerOne.id).emit("updateScore", score, false);187 }188 else{189 playerOne.isTurn = true;190 playerTwo.isTurn = false;191 io.to(playerTwo.id).emit("updateRivalScore", score, false);192 io.to(playerOne.id).emit("updateScore", score, true);193 } 194 }195}196async function endGame(playerOne, playerTwo, common, roomId, io){197 if(playerOne.score >= common.scoreToWin || playerTwo.score >= common.scoreToWin){198 await axios.put(`http://localhost:3001/api/games/${common.gameId}/${playerOne.score}/${playerTwo.score}`);199 if(playerOne.score >= common.scoreToWin){200 await axios.put(`http://localhost:3001/api/games/losser/${common.gameId}/${playerOne.score}/${playerTwo.score}`,{},{201 headers: {202 "x-access-token": playerTwo.token || 1,203 }})204 await axios.put(`http://localhost:3001/api/games/winner/${common.gameId}/${playerOne.score}/${playerTwo.score}`,{},{205 headers: {206 "x-access-token": playerOne.token || 1,207 }})208 io.to(playerOne.id).emit("gameEnds", ({data: playerOne, winner: playerOne.name}));209 io.to(playerTwo.id).emit("gameEnds", ({data: playerOne, winner: playerOne.name}));210 }211 else if(playerTwo.score >= common.scoreToWin){212 await axios.put(`http://localhost:3001/api/games/losser/${common.gameId}/${playerOne.score}/${playerTwo.score}`,{},{213 headers: {214 "x-access-token": playerOne.token || 1,215 }})216 await axios.put(`http://localhost:3001/api/games/winner/${common.gameId}/${playerOne.score}/${playerTwo.score}`,{},{217 headers: {218 "x-access-token": playerTwo.token || 1,219 }})220 io.to(playerOne.id).emit("gameEnds", ({data: playerOne, winner: playerTwo.name}));221 io.to(playerTwo.id).emit("gameEnds", ({data: playerOne, winner: playerTwo.name}));222 }223 // socket.leave(roomId); 224 const clients = io.sockets.adapter.rooms.get(roomId);225 for(const clientId of clients) {226 const clientSocket = io.sockets.sockets.get(clientId);227 clientSocket.leave(roomId)228 };229 delete table.games[roomId];230 return;231 }232}233function quieroEnvido(playerOne, playerOneEnvido, isPlayerOne, playerTwo, playerTwoEnvido, common, roomId, score, bool, io, isPlayerTwo){234 console.log(playerOneEnvido);235 console.log(playerTwoEnvido);236 playerOne.betOptions = [];237 playerOne.bet = false;238 playerTwo.betOptions = [];239 playerTwo.bet = false;240 if(playerOneEnvido > playerTwoEnvido){241 playerOne.score+=score;242 playerTwo.scoreRival+=score;243 setTimeout(()=> io.in(roomId).emit("messages", {msg: `${isPlayerOne? playerTwo.name : playerOne.name}: Tengo ${isPlayerOne? playerTwoEnvido : playerOneEnvido}.`}),200);244 setTimeout(()=> io.in(roomId).emit("messages", {msg: `${!isPlayerOne? playerTwo.name : playerOne.name}: Tengo ${!isPlayerOne? playerTwoEnvido : playerOneEnvido}.`}),400);245 setTimeout(()=> io.in(roomId).emit("messages", {msg: `Gana el envido ${playerOne.name}!`}),800);246 if(isPlayerOne){247 playerOne.isTurn = !bool;248 playerTwo.isTurn = bool;249 io.to(playerTwo.id).emit("quieroEnvido1", bool, 0, score);250 io.to(playerOne.id).emit("quieroEnvido1", !bool, score, 0);251 }252 else if(isPlayerTwo){253 playerOne.isTurn = bool;254 playerTwo.isTurn = !bool;255 io.to(playerOne.id).emit("quieroEnvido1", bool, score, 0);256 io.to(playerTwo.id).emit("quieroEnvido1", !bool, 0, score);257 }258 } 259 else if(playerOneEnvido < playerTwoEnvido){260 playerTwo.score+=score;261 playerOne.scoreRival+=score;262 setTimeout(()=> io.in(roomId).emit("messages", {msg: `${isPlayerOne? playerTwo.name : playerOne.name}: Tengo ${isPlayerOne? playerTwoEnvido : playerOneEnvido}.`}),200);263 setTimeout(()=> io.in(roomId).emit("messages", {msg: `${!isPlayerOne? playerTwo.name : playerOne.name}: Tengo ${!isPlayerOne? playerTwoEnvido : playerOneEnvido}.`}),400);264 setTimeout(()=> io.in(roomId).emit("messages", {msg: `Gana el envido ${playerTwo.name}!`}),800)265 if(isPlayerOne){266 playerOne.isTurn = !bool;267 playerTwo.isTurn = bool;268 io.to(playerTwo.id).emit("quieroEnvido1", bool, score, 0);269 io.to(playerOne.id).emit("quieroEnvido1", !bool, 0, score);270 }271 else if(isPlayerTwo){272 playerOne.isTurn = bool;273 playerTwo.isTurn = !bool;274 io.to(playerOne.id).emit("quieroEnvido1", bool, 0, score);275 io.to(playerTwo.id).emit("quieroEnvido1", !bool, score, 0);276 }277 } 278 else{279 if(playerOne.starts){280 playerOne.score+=score;281 playerTwo.scoreRival+=score;282 setTimeout(()=> io.in(roomId).emit("messages", {msg: `${isPlayerOne? playerTwo.name : playerOne.name}: Tengo ${isPlayerOne? playerTwoEnvido : playerOneEnvido}.`}),200);283 setTimeout(()=> io.in(roomId).emit("messages", {msg: `${!isPlayerOne? playerTwo.name : playerOne.name}: Tengo ${!isPlayerOne? playerTwoEnvido : playerOneEnvido}.`}),400);284 setTimeout(()=> io.in(roomId).emit("messages", {msg: `Empate, gana el envido ${playerOne.name} por empezar turno!`}),800);285 if(isPlayerOne){286 playerOne.isTurn = !bool;287 playerTwo.isTurn = bool;288 io.to(playerTwo.id).emit("quieroEnvido1", bool, 0, score);289 io.to(playerOne.id).emit("quieroEnvido1", !bool, score, 0);290 }291 else if(isPlayerTwo){292 playerOne.isTurn = bool;293 playerTwo.isTurn = !bool;294 io.to(playerOne.id).emit("quieroEnvido1", bool, score, 0);295 io.to(playerTwo.id).emit("quieroEnvido1", !bool, 0, score);296 }297 }298 else{299 playerTwo.score+=score;300 playerOne.scoreRival+=score;301 setTimeout(()=> io.in(roomId).emit("messages", {msg: `${isPlayerOne? playerTwo.name : playerOne.name}: Tengo ${isPlayerOne? playerTwoEnvido : playerOneEnvido}.`}),200);302 setTimeout(()=> io.in(roomId).emit("messages", {msg: `${!isPlayerOne? playerTwo.name : playerOne.name}: Tengo ${!isPlayerOne? playerTwoEnvido : playerOneEnvido}.`}),400);303 setTimeout(()=> io.in(roomId).emit("messages", {msg: `Empate, gana el envido ${playerTwo.name} por empezar turno!`}),800);304 if(isPlayerOne){305 playerOne.isTurn = !bool;306 playerTwo.isTurn = bool;307 io.to(playerTwo.id).emit("quieroEnvido1", bool, score, 0);308 io.to(playerOne.id).emit("quieroEnvido1", !bool, 0, score);309 }310 else if(isPlayerTwo){311 playerOne.isTurn = bool;312 playerTwo.isTurn = !bool;313 io.to(playerOne.id).emit("quieroEnvido1", bool, 0, score);314 io.to(playerTwo.id).emit("quieroEnvido1", !bool, score, 0);315 }316 } 317 } 318}319function noQuieroFaltaEnvido(playerOne, playerTwo, isPlayerOne, common, noQuieroEnvido, io, isPlayerTwo){320 if(common.envidoList.length === 1 && !common.envidoList.includes("realEnvido")){321 noQuieroEnvido(playerOne, playerTwo, isPlayerOne, 1, io, isPlayerTwo); 322 }323 else if(common.envidoList.length === 2 && !common.envidoList.includes("realEnvido")){324 noQuieroEnvido(playerOne, playerTwo, isPlayerOne, 2, io, isPlayerTwo); 325 }326 else if(common.envidoList.length === 2){327 noQuieroEnvido(playerOne, playerTwo, isPlayerOne, 3, io, isPlayerTwo); 328 }329 else if(common.envidoList.length === 3){330 noQuieroEnvido(playerOne, playerTwo, isPlayerOne, 5, io, isPlayerTwo); 331 }332 else if(common.envidoList.length === 4){333 noQuieroEnvido(playerOne, playerTwo, isPlayerOne, 7, io, isPlayerTwo); 334 }335}336exports = module.exports = function(io){337 io.sockets.on('connection', function (socket) {338 // reconnection339 console.log(socket.id)340 if(socket.handshake.auth.isInRoom){341 let roomId = socket.handshake.auth.roomId;342 console.log(roomId)343 if(table.games[roomId]?.playerOne.token === socket.handshake.auth.token){344 table.games[roomId].playerOne.id = socket.id;345 socket.join(roomId)346 io.to(table.games[roomId]?.playerOne?.id).emit("refresh", table.games[roomId]?.playerOne);347 io.to(table.games[roomId]?.playerTwo?.id).emit("refresh", table.games[roomId]?.playerTwo);348 }349 else if(table.games[roomId]?.playerTwo.token === socket.handshake.auth.token){350 table.games[roomId].playerTwo.id = socket.id;351 socket.join(roomId)352 io.to(table.games[roomId]?.playerOne?.id).emit("refresh", table.games[roomId]?.playerOne);353 io.to(table.games[roomId]?.playerTwo?.id).emit("refresh", table.games[roomId]?.playerTwo);354 }355 console.log(table.games[roomId])356 }357 //GAME EVENTS358 socket.on("bet", (betPick, roomId, playerId) => {359 console.log(roomId)360 const playerOne = table.games[roomId]?.playerOne;361 const playerTwo = table.games[roomId]?.playerTwo;362 const common = table.games[roomId]?.common;363 const isPlayerOne = playerOne.id === playerId;364 const isPlayerTwo = playerTwo.id === playerId;365 playerOne.bet = true;366 playerTwo.bet = true;367 368 if(betPick === "ir al mazo") {369 setNewRound(playerOne, playerTwo, common, isPlayerOne, roomId, common.trucoBet, io, isPlayerTwo);370 //emitir como deberia cambiar el jugador de cada cliente371 io.to(playerOne.id).emit("newRoundStarts", table.games[roomId]?.playerOne);372 io.to(playerTwo.id).emit("newRoundStarts", table.games[roomId]?.playerTwo);373 io.in(roomId).emit("messages", { msg: `${isPlayerOne? playerOne.name : playerTwo.name}: IR AL MAZO!`})374 }375 else if(betPick === "quiero truco") {376 common.trucoBet = 2;377 playerOne.betOptions = [];378 playerOne.bet = false;379 playerTwo.betOptions = [];380 playerTwo.bet = false;381 if(isPlayerOne){382 playerOne.isTurn = false;383 playerTwo.isTurn = true;384 io.to(playerTwo.id).emit("quieroTruco", true);385 io.to(playerOne.id).emit("quieroTruco", false);386 }387 else if(isPlayerTwo){388 playerOne.isTurn = true;389 playerTwo.isTurn = false;390 io.to(playerOne.id).emit("quieroTruco", true);391 io.to(playerTwo.id).emit("quieroTruco", false);392 }393 io.in(roomId).emit("messages", { msg: `${isPlayerOne? playerOne.name : playerTwo.name}: QUIERO TRUCO!`}) 394 }395 else if(betPick === "no quiero truco") {396 setNewRound(playerOne, playerTwo, common, isPlayerOne, roomId, common.trucoBet, io, isPlayerTwo);397 //emitir como deberia cambiar el jugador de cada cliente398 io.to(playerOne.id).emit("newRoundStarts", table.games[roomId].playerOne);399 io.to(playerTwo.id).emit("newRoundStarts", table.games[roomId].playerTwo);400 io.in(roomId).emit("messages", { msg: `${isPlayerOne? playerOne.name : playerTwo.name}: NO QUIERO TRUCO!`}) 401 }402 else if(betPick === "quiero retruco") {403 common.trucoBet = 3;404 playerOne.betOptions = [];405 playerOne.bet = false;406 playerTwo.betOptions = [];407 playerTwo.bet = false;408 if(isPlayerOne){409 playerOne.isTurn = true;410 playerTwo.isTurn = false;411 io.to(playerTwo.id).emit("quieroTruco", false);412 io.to(playerOne.id).emit("quieroTruco", true);413 }414 else if(isPlayerTwo){415 playerOne.isTurn = false;416 playerTwo.isTurn = true;417 io.to(playerOne.id).emit("quieroTruco", false);418 io.to(playerTwo.id).emit("quieroTruco", true);419 }420 io.in(roomId).emit("messages", { msg: `${isPlayerOne? playerOne.name : playerTwo.name}: QUIERO RETRUCO!`}) 421 }422 else if(betPick === "no quiero retruco") {423 setNewRound(playerOne, playerTwo, common, isPlayerOne, roomId, common.trucoBet, io, isPlayerTwo);424 //emitir como deberia cambiar el jugador de cada cliente425 io.to(playerOne.id).emit("newRoundStarts", table.games[roomId].playerOne);426 io.to(playerTwo.id).emit("newRoundStarts", table.games[roomId].playerTwo);427 io.in(roomId).emit("messages", { msg: `${isPlayerOne? playerOne.name : playerTwo.name}: NO QUIERO RETRUCO!`}) 428 }429 else if(betPick === "quiero valeCuatro") {430 common.trucoBet = 4;431 playerOne.betOptions = [];432 playerOne.bet = false;433 playerTwo.betOptions = [];434 playerTwo.bet = false;435 if(isPlayerOne){436 playerOne.isTurn = false;437 playerTwo.isTurn = true;438 io.to(playerTwo.id).emit("quieroTruco", true);439 io.to(playerOne.id).emit("quieroTruco", false);440 }441 else if(isPlayerTwo){442 playerOne.isTurn = true;443 playerTwo.isTurn = false;444 io.to(playerOne.id).emit("quieroTruco", true);445 io.to(playerTwo.id).emit("quieroTruco", false);446 }447 io.in(roomId).emit("messages", { msg: `${isPlayerOne? playerOne.name : playerTwo.name}: QUIERO VALE CUATRO!`}) 448 }449 else if(betPick === "no quiero valeCuatro") {450 setNewRound(playerOne, playerTwo, common, isPlayerOne, roomId, common.trucoBet, io, isPlayerTwo);451 //emitir como deberia cambiar el jugador de cada cliente452 io.to(playerOne.id).emit("newRoundStarts", table.games[roomId].playerOne);453 io.to(playerTwo.id).emit("newRoundStarts", table.games[roomId].playerTwo);454 io.in(roomId).emit("messages", { msg: `${isPlayerOne? playerOne.name : playerTwo.name}: NO QUIERO VALE CUATRO!`}) 455 }456 else if(betPick === "envido1"){457 common.envidoList.push("envido");458 playerOne.bet = true;459 playerTwo.bet = true;460 if(isPlayerOne){461 playerOne.betOptions = [];462 playerOne.isTurn = false;463 playerTwo.betOptions = table.betsList.envido1;464 playerTwo.isTurn = true;465 io.to(playerTwo.id).emit("envido1", table.betsList.envido1, true);466 io.to(playerOne.id).emit("envido1", [], false);467 }468 else if(isPlayerTwo){469 playerTwo.betOptions = [];470 playerTwo.isTurn = false;471 playerOne.betOptions = table.betsList.envido1;472 playerOne.isTurn = true;473 io.to(playerTwo.id).emit("envido1", [], false);474 io.to(playerOne.id).emit("envido1", table.betsList.envido1, true);475 }476 io.in(roomId).emit("messages", { msg: `${isPlayerOne? playerOne.name : playerTwo.name}: ENVIDO!`}) 477 }478 else if(betPick === "quiero envido1"){479 const playerOneEnvido = envidoCount(common.playerOneHand);480 const playerTwoEnvido = envidoCount(common.playerTwoHand);481 io.in(roomId).emit("messages", { msg: `${isPlayerOne? playerOne.name : playerTwo.name}: QUIERO ENVIDO!`}); 482 quieroEnvido(playerOne, playerOneEnvido, isPlayerOne, playerTwo, playerTwoEnvido, common, roomId, 2, true, io, isPlayerTwo); 483 }484 else if(betPick === "no quiero envido1"){485 noQuieroEnvido(playerOne, playerTwo, isPlayerOne, 1, io, isPlayerTwo); 486 io.in(roomId).emit("messages", {msg: `${isPlayerOne? playerOne.name : playerTwo.name}: NO QUIERO ENVIDO!`})487 }488 else if(betPick === "envido2"){489 common.envidoList.push("envido");490 if(isPlayerOne){491 playerOne.betOptions = [];492 playerOne.isTurn = false;493 playerTwo.betOptions = table.betsList.envido2;494 playerTwo.isTurn = true;495 io.to(playerTwo.id).emit("envido1", table.betsList.envido2, true);496 io.to(playerOne.id).emit("envido1", [], false);497 }498 else if(isPlayerTwo){499 playerTwo.betOptions = [];500 playerTwo.isTurn = false;501 playerOne.betOptions = table.betsList.envido2;502 playerOne.isTurn = true;503 io.to(playerTwo.id).emit("envido1", [], false);504 io.to(playerOne.id).emit("envido1", table.betsList.envido2, true);505 }506 io.in(roomId).emit("messages", { msg: `${isPlayerOne? playerOne.name : playerTwo.name}: ENVIDO!`}) 507 }508 else if(betPick === "quiero envido2"){509 const playerOneEnvido = envidoCount(common.playerOneHand);510 const playerTwoEnvido = envidoCount(common.playerTwoHand);511 io.in(roomId).emit("messages", { msg: `${isPlayerOne? playerOne.name : playerTwo.name}: QUIERO ENVIDO!`});512 quieroEnvido(playerOne, playerOneEnvido, isPlayerOne, playerTwo, playerTwoEnvido, common, roomId, 4, false, io, isPlayerTwo); 513 }514 else if(betPick === "no quiero envido2"){515 noQuieroEnvido(playerOne, playerTwo, isPlayerOne, 2, io, isPlayerTwo); 516 io.in(roomId).emit("messages", {msg: `${isPlayerOne? playerOne.name : playerTwo.name}: NO QUIERO ENVIDO!`})517 }518 else if(betPick === "realEnvido"){519 common.envidoList.push("realEnvido");520 if(isPlayerOne){521 playerOne.betOptions = [];522 playerOne.isTurn = false;523 playerTwo.betOptions = table.betsList.realEnvido;524 playerTwo.isTurn = true;525 io.to(playerTwo.id).emit("envido1", table.betsList.realEnvido, true);526 io.to(playerOne.id).emit("envido1", [], false);527 }528 else if(isPlayerTwo){529 playerTwo.betOptions = [];530 playerTwo.isTurn = false;531 playerOne.betOptions = table.betsList.realEnvido;532 playerOne.isTurn = true;533 io.to(playerTwo.id).emit("envido1", [], false);534 io.to(playerOne.id).emit("envido1", table.betsList.realEnvido, true);535 }536 io.in(roomId).emit("messages", { msg: `${isPlayerOne? playerOne.name : playerTwo.name}: REAL ENVIDO!`}) 537 }538 else if(betPick === "quiero realEnvido"){539 const playerOneEnvido = envidoCount(common.playerOneHand);540 const playerTwoEnvido = envidoCount(common.playerTwoHand);541 let bool = false;542 io.in(roomId).emit("messages", { msg: `${isPlayerOne? playerOne.name : playerTwo.name}: QUIERO REAL ENVIDO!`}) 543 for (let i = 0; i < common.envidoList.length; i++) {544 common.envidoList[i] === "envido"? common.envidoBet += 2 : common.envidoBet +=3;545 bool = !bool;546 }547 quieroEnvido(playerOne, playerOneEnvido, isPlayerOne, playerTwo, playerTwoEnvido, common, roomId, common.envidoBet, bool, io, isPlayerTwo); 548 }549 else if(betPick === "no quiero realEnvido"){550 let bool = false;551 for (let i = 0; i < common.envidoList.length; i++) {552 common.envidoList[i] === "envido"? common.envidoBet += 2 : common.envidoBet +=3;553 bool = !bool;554 }555 common.envidoBet = Math.floor(common.envidoBet/2);556 if(common.envidoBet === 3) common.envidoBet = 4;557 noQuieroEnvido(playerOne, playerTwo, isPlayerOne, common.envidoBet, io, isPlayerTwo); 558 io.in(roomId).emit("messages", {msg: `${isPlayerOne? playerOne.name : playerTwo.name}: NO QUIERO REAL ENVIDO!`})559 }560 else if(betPick === "faltaEnvido"){561 common.envidoList.push("faltaEnvido");562 if(isPlayerOne){563 playerOne.betOptions = [];564 playerOne.isTurn = false;565 playerTwo.betOptions = table.betsList.faltaEnvido;566 playerTwo.isTurn = true;567 io.to(playerTwo.id).emit("envido1", table.betsList.faltaEnvido, true);568 io.to(playerOne.id).emit("envido1", [], false);569 }570 else if(isPlayerTwo){571 playerTwo.betOptions = [];572 playerTwo.isTurn = false;573 playerOne.betOptions = table.betsList.faltaEnvido;574 playerOne.isTurn = true;575 io.to(playerTwo.id).emit("envido1", [], false);576 io.to(playerOne.id).emit("envido1", table.betsList.faltaEnvido, true);577 };578 io.in(roomId).emit("messages", {msg: `${isPlayerOne? playerOne.name : playerTwo.name}: FALTA ENVIDO!`})579 }580 else if(betPick === "quiero faltaEnvido"){581 const playerOneEnvido = envidoCount(common.playerOneHand);582 const playerTwoEnvido = envidoCount(common.playerTwoHand);583 let bool = false;584 for (let i = 0; i < common.envidoList.length; i++) {585 common.envidoList[i] === "envido"? common.envidoBet += 2 : common.envidoBet +=3;586 bool = !bool;587 }588 let faltaEnvidoScore = 0;589 if(playerOne.score > playerTwo.score){590 faltaEnvidoScore = playerOne.score < 15? 15-playerOne.score : 30-playerOne.score;591 }592 else{593 faltaEnvidoScore = playerTwo.score < 15? 15-playerTwo.score : 30-playerTwo.score;594 }595 quieroEnvido(playerOne, playerOneEnvido, isPlayerOne, playerTwo, playerTwoEnvido, common, roomId, faltaEnvidoScore, bool, io, isPlayerTwo); 596 io.in(roomId).emit("messages", { msg: `${isPlayerOne? playerOne.name : playerTwo.name}: QUIERO FALTA ENVIDO!`});597 }598 else if(betPick === "no quiero faltaEnvido"){599 let bool = true;600 for (let i = 0; i < common.envidoList.length; i++) {601 bool = !bool;602 }603 console.log(common.envidoList)604 if(isPlayerOne){605 noQuieroFaltaEnvido(playerOne, playerTwo, isPlayerOne, common, noQuieroEnvido, io, isPlayerTwo);606 } 607 else if(isPlayerTwo){608 noQuieroFaltaEnvido(playerOne, playerTwo, isPlayerOne, common, noQuieroEnvido, io, isPlayerTwo);609 } 610 io.in(roomId).emit("messages", {msg: `${isPlayerOne? playerOne.name : playerTwo.name}: NO QUIERO FALTA ENVIDO!`}); 611 }612 else{613 playerOne.bet = true;614 playerTwo.bet = true;615 if(isPlayerOne){616 playerOne.isTurn = false;617 playerTwo.isTurn = true;618 playerTwo.betOptions = table.betsList[betPick];619 io.to(playerTwo.id).emit("bet", table.betsList[betPick], true, true);620 }621 else if(isPlayerTwo){622 playerOne.isTurn = true;623 playerTwo.isTurn = false;624 playerOne.betOptions = table.betsList[betPick];625 io.to(playerOne.id).emit("bet", table.betsList[betPick], true, true);626 } 627 io.in(roomId).emit("messages", { msg: `${isPlayerOne? playerOne.name : playerTwo.name}: ${betPick.toUpperCase()}!`});628 }629 endGame(playerOne, playerTwo, common, roomId, io);630 axios.put(`http://localhost:3001/api/games/${common.gameId}/${playerOne.score}/${playerTwo.score}`); 631 });632 socket.on("playCard", (card, roomId, playerId) => {633 const playerOne = table.games[roomId].playerOne;634 const playerTwo = table.games[roomId].playerTwo;635 const common = table.games[roomId].common;636 const isPlayerOne = playerOne.id === playerId;637 const isPlayerTwo = playerTwo.id === playerId;638 if(isPlayerOne){639 playerTwo.tableRival.push(card);640 playerTwo.isTurn = true;641 playerOne.tablePlayer.push(card);642 playerOne.hand = playerOne.hand.filter(cardH=> card.id !== cardH.id);643 playerOne.isTurn = false;644 if(playerOne.tablePlayer[0] && playerTwo.tablePlayer[0] &&645 !playerOne.tablePlayer[1] && !playerTwo.tablePlayer[1] &&646 !playerOne.tablePlayer[2] && !playerTwo.tablePlayer[2]){647 io.to(playerTwo.id).emit("playCard", card, false);648 }649 else if(playerOne.tablePlayer[1] && playerTwo.tablePlayer[1] &&650 !playerOne.tablePlayer[2] && !playerTwo.tablePlayer[2]){651 io.to(playerTwo.id).emit("playCard", card, false);652 }653 else io.to(playerTwo.id).emit("playCard", card, true);654 }655 else if(isPlayerTwo){656 playerOne.tableRival.push(card);657 playerOne.isTurn = true;658 playerTwo.tablePlayer.push(card);659 playerTwo.hand = playerTwo.hand.filter(cardH=> card.id !== cardH.id);660 playerTwo.isTurn = false;661 if(playerOne.tablePlayer[0] && playerTwo.tablePlayer[0] &&662 !playerOne.tablePlayer[1] && !playerTwo.tablePlayer[1] &&663 !playerOne.tablePlayer[2] && !playerTwo.tablePlayer[2]){664 io.to(playerOne.id).emit("playCard", card, false);665 }666 else if(playerOne.tablePlayer[1] && playerTwo.tablePlayer[1] &&667 !playerOne.tablePlayer[2] && !playerTwo.tablePlayer[2]){668 io.to(playerOne.id).emit("playCard", card, false);669 }670 else io.to(playerOne.id).emit("playCard", card, true);671 }672 checkWinnerCards(0, playerOne, playerTwo, common, roomId, io);673 checkWinnerCards(1, playerOne, playerTwo, common, roomId, io);674 checkWinnerCards(2, playerOne, playerTwo, common, roomId, io);675 console.log(common.roundResults)676 //revisar ganador de mano677 if(common.roundResults.length >= 2){678 let winner = false;679 if((common.roundResults.filter(round => round === "playerOne").length > 1) || 680 (common.roundResults.filter(round => round === "tie").length === 2 && common.roundResults.some(round => round === "playerOne")) ||681 common.roundResults.every(round => round === "tie") && common.roundResults.length === 3 && playerOne.starts){682 winner = true;683 playerOne.score += common.trucoBet;684 playerTwo.scoreRival += common.trucoBet;685 io.in(roomId).emit("messages", {msg: `GANADOR MANO ${playerOne.name}!`});686 }687 else if((common.roundResults.filter(round => round === "playerTwo").length > 1) || 688 (common.roundResults.filter(round => round === "tie").length === 2 && common.roundResults.some(round => round === "playerTwo"))||689 common.roundResults.every(round => round === "tie") && common.roundResults.length === 3 && playerTwo.starts){690 winner = true;691 playerTwo.score += common.trucoBet;692 playerOne.scoreRival += common.trucoBet;693 io.in(roomId).emit("messages", {msg: `GANADOR MANO ${playerTwo.name}!`});694 }695 else if(common.roundResults.length === 2 && common.roundResults[0] === "tie" && common.roundResults[1] !== "tie"){696 winner = true;697 if(common.roundResults[1] === "playerOne"){698 playerTwo.score += common.trucoBet;699 playerOne.scoreRival += common.trucoBet;700 io.in(roomId).emit("messages", {msg: `GANADOR MANO ${playerOne.name}!`});701 }702 else if(common.roundResults[1] === "playerTwo"){703 playerOne.score += common.trucoBet;704 playerTwo.scoreRival += common.trucoBet;705 io.in(roomId).emit("messages", {msg: `GANADOR MANO ${playerTwo.name}!`});706 }707 }708 else if(common.roundResults.length === 3){709 winner = true;710 if(common.roundResults[0] === "playerOne"){711 playerTwo.score += common.trucoBet;712 playerOne.scoreRival += common.trucoBet;713 io.in(roomId).emit("messages", {msg: `GANADOR MANO ${playerOne.name}!`});714 }715 else if(common.roundResults[0] === "playerTwo"){716 playerOne.score += common.trucoBet;717 playerTwo.scoreRival += common.trucoBet;718 io.in(roomId).emit("messages", {msg: `GANADOR MANO ${playerTwo.name}!`});719 }720 }721 //revisar si algun jugador ya gano antes de iniciar nueva mano722 endGame(playerOne, playerTwo, common, roomId, io);723 724 if(winner){725 //reiniciar estados de playerOne, Two y common para empezar siguiente ronda726 table.games[roomId].playerOne = {...table.games[roomId].playerOne, turnNumber: 1,727 tableRival: [],728 tablePlayer: [],729 bet: false,730 roundResults: [],}731 table.games[roomId].playerTwo = {...table.games[roomId].playerTwo, turnNumber: 1,732 tableRival: [],733 tablePlayer: [],734 bet: false,735 roundResults: [],}736 table.games[roomId].common = {...table.games[roomId].common, envidoList: [],737 trucoBet: 1,738 envidoBet: 0,739 cumulativeScore: 0,740 roundResults: [],741 turn: 1,}742 let deck = buildDeck(); //contruye deck743 deck = shuffleDeck(deck); //baraja deck744 const [playerAhand, playerBhand] = getHands(deck); //obtiene manos de 3 cartas de dos jugadores745 746 //manos iniciales al iniciar partida747 table.games[roomId].playerOne.hand = playerAhand;748 table.games[roomId].playerTwo.hand = playerBhand;749 //manos copias al iniciar partida750 table.games[roomId].common.playerOneHand = [...playerAhand];751 table.games[roomId].common.playerTwoHand = [...playerBhand];752 753 //dejar las apuestas al comienzo754 table.games[roomId].playerOne.betOptions = table.betsList.firstTurn;755 table.games[roomId].playerTwo.betOptions = table.betsList.firstTurn;756 757 //cambiar de jugador que inicia758 if(table.games[roomId].playerOne.starts){759 table.games[roomId].playerTwo.isTurn = true;760 table.games[roomId].playerOne.isTurn = false;761 table.games[roomId].playerOne.starts = false;762 table.games[roomId].playerTwo.starts = true;763 }else{764 table.games[roomId].playerOne.isTurn = true;765 table.games[roomId].playerTwo.isTurn = false;766 table.games[roomId].playerOne.starts = true;767 table.games[roomId].playerTwo.starts = false;768 };769 //emitir como deberia cambiar el jugador de cada cliente770 io.to(table.games[roomId].playerOne.id).emit("newRoundStarts", table.games[roomId].playerOne);771 io.to(table.games[roomId].playerTwo.id).emit("newRoundStarts", table.games[roomId].playerTwo);772 }773 axios.put(`http://localhost:3001/api/games/${common.gameId}/${playerOne.score}/${playerTwo.score}`);774 }775 776 });777 socket.on("changeTurn", (roomId, playerId)=>{778 if(table.games[roomId].playerOne.id === playerId){779 io.to(table.games[roomId].playerTwo.id).emit("changeTurn", false);780 io.to(table.games[roomId].playerOne.id).emit("changeTurn", true);781 }782 else{783 io.to(table.games[roomId].playerTwo.id).emit("changeTurn", true);784 io.to(table.games[roomId].playerOne.id).emit("changeTurn", false);785 }786 }); 787 socket.on("refresh", (roomId)=>{788 console.log("refresh")789 // const clients = io.sockets.adapter.rooms.get(roomId);790 // for(const clientId of clients) {791 // const clientSocket = io.sockets.sockets.get(clientId);792 io.to(table.games[roomId]?.playerOne?.id).emit("refresh", table.games[roomId]?.playerOne);793 io.to(table.games[roomId]?.playerTwo?.id).emit("refresh", table.games[roomId]?.playerTwo);794 // };795 })796 });...

Full Screen

Full Screen

jquery.jplayer.inspector.js

Source:jquery.jplayer.inspector.js Github

copy

Full Screen

...248 jPlayerInfo += "<code>htmlElement.video.canPlayType = " + (typeof $(this).data("jPlayerInspector").jPlayer.data("jPlayer").htmlElement.video.canPlayType) +"</code>";249 }250 jPlayerInfo += "</p>";251 jPlayerInfo += "<p>This instance is using the constructor options:<br />"252 + "<code>$('#" + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").internal.self.id + "').jPlayer({<br />"253 + "&nbsp;swfPath: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "swfPath") + "',<br />"254 + "&nbsp;solution: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "solution") + "',<br />"255 + "&nbsp;supplied: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "supplied") + "',<br />"256 + "&nbsp;preload: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "preload") + "',<br />"257 258 + "&nbsp;volume: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "volume") + ",<br />"259 260 + "&nbsp;muted: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "muted") + ",<br />"261 + "&nbsp;backgroundColor: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "backgroundColor") + "',<br />"262 + "&nbsp;cssSelectorAncestor: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelectorAncestor") + "',<br />"263 + "&nbsp;cssSelector: {";264 var cssSelector = $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelector");265 for(prop in cssSelector) {266 267 // jPlayerInfo += "<br />&nbsp;&nbsp;" + prop + ": '" + cssSelector[prop] + "'," // This works too of course, but want to use option method for deep keys.268 jPlayerInfo += "<br />&nbsp;&nbsp;" + prop + ": '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelector." + prop) + "',"269 }270 jPlayerInfo = jPlayerInfo.slice(0, -1); // Because the sloppy comma was bugging me.271 jPlayerInfo += "<br />&nbsp;},<br />"272 + "&nbsp;errorAlerts: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "errorAlerts") + ",<br />"273 274 + "&nbsp;warningAlerts: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "warningAlerts") + "<br />"275 + "});</code></p>";276 $(this).data("jPlayerInspector").configJq.html(jPlayerInfo);277 return this;278 },279 updateStatus: function() { // This displays information about jPlayer's status in the inspector280 $(this).data("jPlayerInspector").statusJq.html(281 "<p>jPlayer is " +282 ($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.paused ? "paused" : "playing") +283 " at time: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentTime*10)/10 + "s." +284 " (d: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.duration*10)/10 + "s" +285 ", sp: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.seekPercent) + "%" +286 ", cpr: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentPercentRelative) + "%" +287 ", cpa: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentPercentAbsolute) + "%)</p>"288 );...

Full Screen

Full Screen

useApplicationData.js

Source:useApplicationData.js Github

copy

Full Screen

...376 }377 return () => channel.unsubscribe()378 }, [game, user])379 useEffect(() => {380 if (players.length > 0) for (let i = 0; i < players.length; i++) if (players[i].player.user_id === user.id) setCurrentPlayer(i)381 }, [players.length, user])382 useEffect(() => {383 if (playersInitialized !== 0 && players.length > 0) {384 players.forEach((player, index) => {385 if (player.player.moving) rollDice(Math.abs(player.player.final_position - player.player.position), index)386 })387 setPlayersInitialized(0)388 }389 }, [playersInitialized, players])390 useEffect(() => {391 if (update.message === 'Game created') updateGames(update.game)392 if (update.message === 'Game ended') endGame(update.game)393 if (update.message === 'Player joined') addPlayer(update.player)394 if (update.message === 'Player joined - game full') fullGame(update.game)395 if (update.message === 'Player moved') updatePlayerPosition(update.player)396 if (update.message === 'Player passed go') updatePlayerScore(update.player)397 if (update.message === 'Book submitted') getTiles(board)398 }, [update])399 useEffect(() => {400 if (players.length > 0 && chanceUsed !== -1) {401 axios.get(`/api/boards/${board}/players/${players[chanceUsed].player.id}/draw_chance`)402 .then((response) => {403 setPlayers((current) => {404 const newPlayers = [...current]405 newPlayers[chanceUsed] = {...newPlayers[chanceUsed], player: {...newPlayers[chanceUsed].player, chance: newPlayers[chanceUsed].player.chance ? newPlayers[chanceUsed].player.chance - 1 : 1 } }406 return newPlayers407 })...

Full Screen

Full Screen

vimeo.js

Source:vimeo.js Github

copy

Full Screen

...120 ui.setPoster.call(player, url.href).catch(() => {});121 });122 // Setup instance123 // https://github.com/vimeo/player.js124 player.embed = new window.Vimeo.Player(iframe, {125 autopause: player.config.autopause,126 muted: player.muted,127 });128 player.media.paused = true;129 player.media.currentTime = 0;130 // Disable native text track rendering131 if (player.supported.ui) {132 player.embed.disableTextTrack();133 }134 // Create a faux HTML5 API using the Vimeo API135 player.media.play = () => {136 assurePlaybackState.call(player, true);137 return player.embed.play();138 };...

Full Screen

Full Screen

99-stories.js

Source:99-stories.js Github

copy

Full Screen

...27 if (createdVideoID === clicked_box){ 28 console.log('ir jau tads video'); 29 } else { 30 // onYouTubeIframeAPIReady(clicked_box) 31 player = new YT.Player('player-' + clicked_box, { 32 height: '349', 33 width: '560', 34 videoId: videoID, 35 playerVars: { 'color': 'white', 'modestbranding': 1, 'rel': 0, 'enablejsapi': 1 }, 36 events: { 37 'onReady': onPlayerReady, 38 'onStateChange': onPlayerStateChange 39 }, 40 }) 41 return createdVideoID = clicked_box; 42 } 43 44 45}//Open Video Modulee 46 47function playSmallVideo(clicked_box) { 48 var playerBtn = document.getElementById("svg-box-container-player-" + clicked_box); 49 // console.log(clicked_box); 50 // console.log(player.f.id); 51 // var player = document.getElementById("player-" + clicked_box); 52 console.log(player); 53 console.log(playerBtn); 54 // console.log(clicked_box); 55 // console.log(newplayer); 56 if (playerStatus === 2 || playerStatus === -1 || playerStatus === -5) { //paused or unstarted or video cued 57 // player.loadVideoById({videoId:'1PalAURGxtM'}); 58 player.playVideo(); 59 playerBtn.style.opacity = 0; 60 } else if (playerStatus === 3 || playerStatus === 1) { //buffering or playing 61 player.pauseVideo(); 62 playerBtn.style.opacity = 1; 63 } 64 65} 66 67function onYouTubeIframeAPIReady(index) { 68 69 // for (i = 0; i <= row.length; i++) { 70 71 // console.log(player); 72 // var videoID = row[index].field_5faa821360bbb; 73 74 // player = new YT.Player('player-' + index, { 75 // height: '349', 76 // width: '560', 77 // videoId: videoID, 78 // playerVars: { 'color': 'white', 'modestbranding': 1, 'rel': 0, 'enablejsapi': 1 }, 79 // events: { 80 // 'onReady': onPlayerReady, 81 // 'onStateChange': onPlayerStateChange 82 // }, 83 84 // }) 85 // console.log(player); 86 // console.log(player.f.id === '#player-' + index ); 87 // if (player.f.id !== '#player-' + index){ 88 89 90 91 // } 92} 93var playerStatus = 2; 94function onPlayerStateChange(event) { 95 playerStatus = event.data; 96 // console.log(player.f.id); 97 // console.log(clicked_box); 98 var playerBtn = document.getElementById("svg-box-container-" + player.f.id); 99 // console.log(player.f.id); 100 // console.log(playerBtn); 101 102 if (playerStatus === 2 || playerStatus === -1 || playerStatus === -5) { //paused or unstarted or video cued 103 // player.playVideo(); 104 playerBtn.style.opacity = 1; 105 } else if (playerStatus === 3 || playerStatus === 1) { //buffering or playing 106 // player.pauseVideo(); 107 playerBtn.style.opacity = 0; 108 } 109} 110function closeModule(clicked_box) {//Close Video Module 111 112 var video = document.getElementById("small-video-" + clicked_box); 113 var modal = document.getElementById("video-modal-" + clicked_box); 114// console.log(player); 115 modal.style.display = "none"; 116 117 // if (player) 118 player.pauseVideo(); 119 120}//Close Video Module 121 122// function playSmallVideo(clicked_box) { 123// var video = document.getElementById("small-video-" + clicked_box); 124// var playerBtn = document.getElementById("small-svg-container" + clicked_box); 125// if (video.paused == true) { 126// // Play the video 127// video.play(); 128// playerBtn.style.opacity = 0; 129// triangle.style.opacity = 0; 130// } else { 131// playerBtn.style.opacity = 1; 132// triangle.style.opacity = 1; 133// video.pause(); 134// } 135// }; 136 137// 2. This code loads the IFrame Player API code asynchronously. 138// var tag = document.createElement('script'); 139 140// tag.src = "https://www.youtube.com/iframe_api"; 141// var firstScriptTag = document.getElementsByTagName('script')[0]; 142// firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 143// // 3. This function creates an <iframe> (and YouTube player) 144// // after the API code downloads. 145 146// var newplayer = []; 147// function onYouTubeIframeAPIReady() { 148 149// for (i = 0; i <= row.length; i++){ 150// var player = []; 151// var videoID = row[i].field_5faa821360bbb; 152 153 154// newplayer = player = new YT.Player('player-' + i, { 155// height: '349', 156// width: '560', 157// videoId: videoID, 158// playerVars: { 'color': 'white', 'modestbranding': 1, 'rel': 0 }, 159// events: { 160// 'onReady': onPlayerReady, 161// 'onStateChange': onPlayerStateChange 162// }, 163 164// }) 165 166// }} 167// 4. The API will call this function when the video player is ready. 168 ...

Full Screen

Full Screen

audio-shortcode.js

Source:audio-shortcode.js Github

copy

Full Screen

1(function($) {2window.audioshortcode = {3 /**4 * Prep the audio player once the page is ready, add listeners, etc5 */6 prep: function( player_id, files, titles, volume, loop ) {7 // check if the player has already been prepped, no-op if it has8 var container = $( '#wp-as-' + player_id + '-container' );9 if ( container.hasClass( 'wp-as-prepped' ) ) {10 return;11 }12 container.addClass( 'wp-as-prepped' );13 // browser doesn't support HTML5 audio, no-op14 if ( ! document.createElement('audio').canPlayType ) {15 return;16 }17 // if the browser removed the script, no-op18 player = $( '#wp-as-' + player_id ).get(0);19 if ( typeof player === 'undefined' ) {20 return;21 }22 this[player_id] = [];23 this[player_id].i = 0;24 this[player_id].files = files;25 this[player_id].titles = titles;26 player.volume = volume;27 var type_map = {28 'mp3': 'mpeg',29 'wav': 'wav',30 'ogg': 'ogg',31 'oga': 'ogg',32 'm4a': 'mp4',33 'aac': 'mp4',34 'webm': 'webm'35 };36 // strip out all the files that can't be played37 for ( var i = this[player_id].files.length-1; i >= 0; i-- ) {38 var extension = this[player_id].files[i].split( '.' ).pop();39 var type = 'audio/' + type_map[extension];40 if ( ! player.canPlayType( type ) ) {41 this.remove_track( player_id, i );42 }43 }44 // bail if there are no more good files45 if ( 0 == this[player_id].files.length ) {46 return;47 }48 player.src = this[player_id].files[0];49 // show the controls if there are still 2+ files remaining50 if ( 1 < this[player_id].files.length ) {51 $( '#wp-as-' + player_id + '-controls' ).show();52 }53 player.addEventListener( 'error', function() {54 audioshortcode.remove_track( player_id, audioshortcode[player_id].i );55 if ( 0 < audioshortcode[player_id].files.length ) {56 audioshortcode[player_id].i--;57 audioshortcode.next_track( player_id, false, loop ); 58 }59 }, false );60 player.addEventListener( 'ended', function() {61 audioshortcode.next_track( player_id, false, loop );62 }, false );63 player.addEventListener( 'play', function() {64 var i = audioshortcode[player_id].i;65 var titles = audioshortcode[player_id].titles;66 $( '#wp-as-' + player_id + '-playing' ).text( ' ' + titles[i] );67 }, false );68 player.addEventListener( 'pause', function() {69 $( '#wp-as-' + player_id + '-playing' ).text( '' );70 }, false );71 },72 /**73 * Remove the track and update the player/controls if needed74 */75 remove_track: function( player_id, index ) {76 this[player_id].files.splice( index, 1 );77 this[player_id].titles.splice( index, 1 );78 // get rid of player/controls if they can't be played79 if ( 0 == this[player_id].files.length ) {80 $( '#wp-as-' + player_id + '-container' ).html( $( '#wp-as-' + player_id + '-nope' ).html() );81 $( '#wp-as-' + player_id + '-controls' ).html( '' );82 } else if ( 1 == this[player_id].files.length ) {83 $( '#wp-as-' + player_id + '-controls' ).html( '' );84 }85 },86 /**87 * Change the src of the player, load the file, then play it88 */89 start_track: function( player_id, file ) {90 var player = $( '#wp-as-' + player_id ).get(0);91 player.src = file;92 player.load();93 player.play();94 },95 /**96 * Play the previous track97 */98 prev_track: function( player_id ) {99 var player = $( '#wp-as-' + player_id ).get(0);100 var files = this[player_id].files;101 if ( player.paused || 0 == this[player_id].i ) { 102 return 103 };104 player.pause();105 if ( 0 < this[player_id].i ) {106 this[player_id].i--;107 this.start_track( player_id, files[this[player_id].i] );108 }109 },110 /**111 * Play the next track112 */113 next_track: function( player_id, fromClick, loop ) {114 var player = $( '#wp-as-' + player_id ).get(0);115 var files = this[player_id].files;116 if ( fromClick && ( player.paused || files.length-1 == this[player_id].i ) ) {117 return;118 }119 player.pause();120 if ( files.length-1 > this[player_id].i ) {121 this[player_id].i++;122 this.start_track( player_id, files[this[player_id].i] );123 } else if ( loop ) {124 this[player_id].i = 0;125 this.start_track( player_id, 0 );126 } else {127 this[player_id].i = 0;128 player.src = files[0];129 $( '#wp-as-' + player_id + '-playing' ).text( '' );130 }131 }132};...

Full Screen

Full Screen

script.js

Source:script.js Github

copy

Full Screen

...71// const animate = () => {72// ctx.clearRect(0, 0, canvas.width, canvas.height)73// ctx.drawImage(background, 0, 0, canvas.width, canvas.height);74// drawSprite(playerSprite, player.width * player.frameX, player.height * player.frameY, player.width, player.height, player.x, player.y, player.width, player.height);75// movePlayer();76// handlePlayerFrame();77// requestAnimationFrame(animate);78// }79// animate();80let fps, fpsInterval, startTime, now, then, elapsed;81const startAnimating = (fps) => {82 fpsInterval = 1000/fps;83 then = Date.now();84 startTime = then;85 animate();86}87const animate = () => {88 requestAnimationFrame(animate);89 now = Date.now();90 elapsed = now - then;91 if (elapsed > fpsInterval) {92 then = now - (elapsed % fpsInterval);93 ctx.clearRect(0, 0, canvas.width, canvas.height)94 ctx.drawImage(background, 0, 0, canvas.width, canvas.height);95 drawSprite(playerSprite, player.width * player.frameX, player.height * player.frameY, player.width, player.height, player.x, player.y, player.width, player.height);96 movePlayer();97 handlePlayerFrame();98 }99}100startAnimating(50);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var Player = require('./Player.js');2var Song = require('./Song.js');3describe("Player", function() {4 var player;5 var song;6 beforeEach(function() {7 player = new Player();8 song = new Song();9 });10 it("should be able to play a Song", function() {11 player.play(song);12 expect(player.currentlyPlayingSong).toEqual(song);13 expect(player).toBePlaying(song);14 });15 describe("when song has been paused", function() {16 beforeEach(function() {17 player.play(song);18 player.pause();19 });20 it("should indicate that the song is currently paused", function() {21 expect(player.isPlaying).toBeFalsy();22 expect(player).not.toBePlaying(song);23 });24 it("should be possible to resume", function() {25 player.resume();26 expect(player.isPlaying).toBeTruthy();27 expect(player.currentlyPlayingSong).toEqual(song);28 });29 });30 it("tells the current song if the user has made it a favorite", function() {31 spyOn(song, 'persistFavoriteStatus');32 player.play(song);33 player.makeFavorite();34 expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);35 });36 describe("#resume", function() {37 it("should throw an exception if song is already playing", function() {38 player.play(song);39 expect(function() {40 player.resume();41 }).toThrowError("song is already playing");42 });43 });44});45function Player() {46 this.currentlyPlayingSong = null;47 this.isPlaying = false;48}49Player.prototype.play = function(song) {50 this.currentlyPlayingSong = song;51 this.isPlaying = true;52};53Player.prototype.pause = function() {54 this.isPlaying = false;55};56Player.prototype.resume = function() {57 if (this.isPlaying) {58 throw new Error("song is already playing");59 }60 this.isPlaying = true;61};62Player.prototype.makeFavorite = function() {63 this.currentlyPlayingSong.persistFavoriteStatus(true);64};65module.exports = Player;66function Song() {67}68Song.prototype.persistFavoriteStatus = function(value) {69 throw new Error("not yet implemented");70};

Full Screen

Using AI Code Generation

copy

Full Screen

1var Player = require('./player.js');2var Song = require('./song.js');3describe("Player", function() {4 var player;5 var song;6 beforeEach(function() {7 player = new Player();8 song = new Song();9 });10 it("should be able to play a Song", function() {11 player.play(song);12 expect(player.currentlyPlayingSong).toEqual(song);13 expect(player).toBePlaying(song);14 });15 describe("when song has been paused", function() {16 beforeEach(function() {17 player.play(song);18 player.pause();19 });20 it("should indicate that the song is currently paused", function() {21 expect(player.isPlaying).toBeFalsy();22 expect(player).not.toBePlaying(song);23 });24 it("should be possible to resume", function() {25 player.resume();26 expect(player.isPlaying).toBeTruthy();27 expect(player.currentlyPlayingSong).toEqual(song);28 });29 });30 it("tells the current song if the user has made it a favorite", function() {31 spyOn(song, 'persistFavoriteStatus');32 player.play(song);33 player.makeFavorite();34 expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);35 });36 describe("#resume", function() {37 it("should throw an exception if song is already playing", function() {38 player.play(song);39 expect(function() {40 player.resume();41 }).toThrowError("song is already playing");42 });43 });44});45function Song() {46}47Song.prototype.persistFavoriteStatus = function(value) {48 throw new Error("not yet implemented");49};50module.exports = Song;51function Player() {52 this.currentlyPlayingSong = null;53 this.isPlaying = false;54}55Player.prototype.play = function(song) {56 this.currentlyPlayingSong = song;57 this.isPlaying = true;58};59Player.prototype.pause = function() {60 this.isPlaying = false;61};62Player.prototype.resume = function() {63 if (this.isPlaying) {64 throw new Error("song is already playing");65 }66 this.isPlaying = true;67};68Player.prototype.makeFavorite = function() {69 this.currentlyPlayingSong.persistFavoriteStatus(true);70};

Full Screen

Using AI Code Generation

copy

Full Screen

1var Player = require('./player.js');2var Song = require('./song.js');3describe('Player', function() {4 var player;5 var song;6 beforeEach(function() {7 player = new Player();8 song = new Song();9 });10 it('should be able to play a Song', function() {11 player.play(song);12 expect(player.currentlyPlayingSong).toEqual(song);13 expect(player).toBePlaying(song);14 });15 describe('when song has been paused', function() {16 beforeEach(function() {17 player.play(song);18 player.pause();19 });20 it('should indicate that the song is currently paused', function() {21 expect(player.isPlaying).toBeFalsy();22 expect(player).not.toBePlaying(song);23 });24 it('should be possible to resume', function() {25 player.resume();26 expect(player.isPlaying).toBeTruthy();27 expect(player.currentlyPlayingSong).toEqual(song);28 });29 });30 it('tells the current song if the user has made it a favorite', function() {31 spyOn(song, 'persistFavoriteStatus');32 player.play(song);33 player.makeFavorite();34 expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);35 });36 describe('#resume', function() {37 it('should throw an exception if song is already playing', function() {38 player.play(song);39 expect(function() {40 player.resume();41 }).toThrowError('song is already playing');42 });43 });44});45function Player() {46 this.currentlyPlayingSong = null;47}48Player.prototype.play = function(song) {49 this.currentlyPlayingSong = song;50 this.isPlaying = true;51};52Player.prototype.pause = function() {53 this.isPlaying = false;54};55Player.prototype.resume = function() {56 if (this.isPlaying) {57 throw new Error("song is already playing");58 }59 this.isPlaying = true;60};61Player.prototype.makeFavorite = function() {62 this.currentlyPlayingSong.persistFavoriteStatus(true);63};64module.exports = Player;65function Song() {66}67Song.prototype.persistFavoriteStatus = function(value) {68 throw new Error("not yet implemented");69};70module.exports = Song;

Full Screen

Using AI Code Generation

copy

Full Screen

1var jasmine = require('jasmine-core');2var Player = require('./player.js');3var Song = require('./song.js');4describe('Player', function() {5 var player;6 var song;7 beforeEach(function() {8 player = new Player();9 song = new Song();10 });11 it('should be able to play a Song', function() {12 player.play(song);13 expect(player.currentlyPlayingSong).toEqual(song);14 expect(player).toBePlaying(song);15 });16 describe('when song has been paused', function() {17 beforeEach(function() {18 player.play(song);19 player.pause();20 });21 it('should indicate that the song is currently paused', function() {22 expect(player.isPlaying).toBeFalsy();23 expect(player).not.toBePlaying(song);24 });25 it('should be possible to resume', function() {26 player.resume();27 expect(player.isPlaying).toBeTruthy();28 expect(player.currentlyPlayingSong).toEqual(song);29 });30 });31 it('tells the current song if the user has made it a favorite', function() {32 spyOn(song, 'persistFavoriteStatus');33 player.play(song);34 player.makeFavorite();35 expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);36 });37 describe('#resume', function() {38 it('should throw an exception if song is already playing', function() {39 player.play(song);40 expect(function() {41 player.resume();42 }).toThrowError('song is already playing');43 });44 });45});46function Player() {47 this.currentlyPlayingSong = null;48 this.isPlaying = false;49}50Player.prototype.play = function(song) {51 this.currentlyPlayingSong = song;52 this.isPlaying = true;53};54Player.prototype.pause = function() {55 this.isPlaying = false;56};57Player.prototype.resume = function() {58 if (this.isPlaying) {59 throw new Error("song is already playing");60 }61 this.isPlaying = true;62};63Player.prototype.makeFavorite = function() {64 this.currentlyPlayingSong.persistFavoriteStatus(true);65};66module.exports = Player;67function Song() {68}69Song.prototype.persistFavoriteStatus = function(value) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var Player = require('./Player.js');2var Song = require('./Song.js');3describe("Player", function() {4 beforeEach(function() {5 player = new Player();6 song = new Song();7 });8 it("should be able to play a Song", function() {9 player.play(song);10 expect(player.currentlyPlayingSong).toEqual(song);11 expect(player).toBePlaying(song);12 });13 describe("when song has been paused", function() {14 beforeEach(function() {15 player.play(song);16 player.pause();17 });18 it("should indicate that the song is currently paused", function() {19 expect(player.isPlaying).toBeFalsy();20 expect(player).not.toBePlaying(song);21 });22 it("should be possible to resume", function() {23 player.resume();24 expect(player.isPlaying).toBeTruthy();25 expect(player.currentlyPlayingSong).toEqual(song);26 });27 });28 it("tells the current song if the user has made it a favorite", function() {29 spyOn(song, 'persistFavoriteStatus');30 player.play(song);31 player.makeFavorite();32 expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);33 });34 describe("#resume", function() {35 it("should throw an exception if song is already playing", function() {36 player.play(song);37 expect(function() {38 player.resume();39 }).toThrowError("song is already playing");40 });41 });42});43var Song = function() {44 this.persistFavoriteStatus = function(value) {45 throw new Error("not yet implemented");46 };47};48module.exports = Song;49var Song = require('./Song.js');50var Player = function() {51 this.currentlyPlayingSong = null;52 this.isPlaying = false;53};54Player.prototype.play = function(song) {55 this.currentlyPlayingSong = song;56 this.isPlaying = true;57};58Player.prototype.pause = function() {59 this.isPlaying = false;60};61Player.prototype.resume = function() {62 if (this.isPlaying) {63 throw new Error("song is already playing");64 }

Full Screen

Using AI Code Generation

copy

Full Screen

1var Player = require('../../src/Player.js');2var Song = require('../../src/Song.js');3describe("Player", function() {4 var player;5 var song;6 beforeEach(function() {7 player = new Player();8 song = new Song();9 });10 it("should be able to play a Song", function() {11 player.play(song);12 expect(player.currentlyPlayingSong).toEqual(song);13 expect(player).toBePlaying(song);14 });15 describe("when song has been paused", function() {16 beforeEach(function() {17 player.play(song);18 player.pause();19 });20 it("should indicate that the song is currently paused", function() {21 expect(player.isPlaying).toBeFalsy();22 expect(player).not.toBePlaying(song);23 });24 it("should be possible to resume", function() {25 player.resume();26 expect(player.isPlaying).toBeTruthy();27 expect(player.currentlyPlayingSong).toEqual(song);28 });29 });30 it("tells the current song if the user has made it a favorite", function() {31 spyOn(song, 'persistFavoriteStatus');32 player.play(song);33 player.makeFavorite();34 expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);35 });36 describe("#resume", function() {37 it("should throw an exception if song is already playing", function() {38 player.play(song);39 expect(function() {40 player.resume();41 }).toThrowError("song is already playing");42 });43 });44});45function Song() {46}47Song.prototype.persistFavoriteStatus = function(value) {48 throw new Error("not yet implemented");49};50module.exports = Song;51function Player() {52 this.currentlyPlayingSong = null;53 this.isPlaying = false;54}55Player.prototype.play = function(song) {56 this.currentlyPlayingSong = song;57 this.isPlaying = true;58};59Player.prototype.pause = function() {60 this.isPlaying = false;61};62Player.prototype.resume = function() {63 if (this.isPlaying) {64 throw new Error("song is already playing");65 }66 this.isPlaying = true;67};68Player.prototype.makeFavorite = function() {

Full Screen

Using AI Code Generation

copy

Full Screen

1var jasmine = require('jasmine-core');2var Player = require('./src/Player.js');3var Song = require('./src/Song.js');4describe("Player", function() {5 var player;6 var song;7 beforeEach(function() {8 player = new Player();9 song = new Song();10 });11 it("should be able to play a Song", function() {12 player.play(song);13 expect(player.currentlyPlayingSong).toEqual(song);14 expect(player).toBePlaying(song);15 });16 describe("when song has been paused", function() {17 beforeEach(function() {18 player.play(song);19 player.pause();20 });21 it("should indicate that the song is currently paused", function() {22 expect(player.isPlaying).toBeFalsy();23 expect(player).not.toBePlaying(song);24 });25 it("should be possible to resume", function() {26 player.resume();27 expect(player.isPlaying).toBeTruthy();28 expect(player.currentlyPlayingSong).toEqual(song);29 });30 });31 it("tells the current song if the user has made it a favorite", function() {32 spyOn(song, 'persistFavoriteStatus');33 player.play(song);34 player.makeFavorite();35 expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);36 });37 describe("#resume", function() {38 it("should throw an exception if song is already playing", function() {39 player.play(song);40 expect(function() {41 player.resume();42 }).toThrowError("song is already playing");43 });44 });45});46var jasmine = require('jasmine-core');47function Player() {48 this.currentlyPlayingSong = null;49 this.isPlaying = false;50}51Player.prototype.play = function(song) {52 this.currentlyPlayingSong = song;53 this.isPlaying = true;54};55Player.prototype.pause = function() {56 this.isPlaying = false;57};58Player.prototype.resume = function() {59 if (this.isPlaying) {60 throw new Error("song is already playing");61 }62 this.isPlaying = true;

Full Screen

Using AI Code Generation

copy

Full Screen

1var Player = require('../../app/models/player.js');2var Song = require('../../app/models/song.js');3describe("Player", function() {4 var player;5 var song;6 beforeEach(function() {7 player = new Player();8 song = new Song();9 });10 it("should be able to play a Song", function() {11 player.play(song);12 expect(player.currentlyPlayingSong).toEqual(song);13 expect(player).toBePlaying(song);14 });15 describe("when song has been paused", function() {16 beforeEach(function() {17 player.play(song);18 player.pause();19 });20 it("should indicate that the song is currently paused", function() {21 expect(player.isPlaying).toBeFalsy();22 expect(player).not.toBePlaying(song);23 });24 it("should be possible to resume", function() {25 player.resume();26 expect(player.isPlaying).toBeTruthy();27 expect(player.currentlyPlayingSong).toEqual(song);28 });29 });30 it("tells the current song if the user has made it a favorite", function() {31 spyOn(song, 'persistFavoriteStatus');32 player.play(song);33 player.makeFavorite();34 expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);35 });36 describe("#resume", function() {37 it("should throw an exception if song is already playing", function() {38 player.play(song);39 expect(function() {40 player.resume();41 }).toThrowError("song is already playing");42 });43 });44});45function Player() {46 this.currentlyPlayingSong = null;47 this.isPlaying = false;48}49Player.prototype.play = function(song) {50 this.currentlyPlayingSong = song;51 this.isPlaying = true;52};53Player.prototype.pause = function() {54 this.isPlaying = false;55};56Player.prototype.resume = function() {57 if (this.isPlaying) {58 throw new Error("song is already playing");59 }60 this.isPlaying = true;61};62Player.prototype.makeFavorite = function() {63 this.currentlyPlayingSong.persistFavoriteStatus(true);64};65module.exports = Player;66function Song() {67}68Song.prototype.persistFavoriteStatus = function(value) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var jasmine = require('jasmine-core');2var Player = require('./Player.js');3var Song = require('./Song.js');4var player;5var song;6beforeEach(function() {7 player = new Player();8 song = new Song();9});10describe('Player', function() {11 it('should be able to play a Song', function() {12 player.play(song);13 expect(player.currentlyPlayingSong).toEqual(song);14 expect(player).toBePlaying(song);15 });16});17describe('when song has been paused', function() {18 beforeEach(function() {19 player.play(song);20 player.pause();21 });22 it('should indicate that the song is currently paused', function() {23 expect(player.isPlaying).toBeFalsy();24 expect(player).not.toBePlaying(song);25 });26 it('should be possible to resume', function() {27 player.resume();28 expect(player.isPlaying).toBeTruthy();29 expect(player.currentlyPlayingSong).toEqual(song);30 });31});32describe('when song has not been paused', function() {33 it('should indicate that the song is currently playing', function() {34 player.play(song);35 expect(player.isPlaying).toBeTruthy();36 expect(player.currentlyPlayingSong).toEqual(song);37 });38});39describe('when song has been paused', function() {40 beforeEach(function() {41 player.play(song);42 player.pause();43 });44 it('should indicate that the song is currently paused', function() {45 expect(player.isPlaying).toBeFalsy();46 expect(player).not.toBePlaying(song);47 });48 it('should be possible to resume', function() {49 player.resume();50 expect(player.isPlaying).toBeTruthy();51 expect(player.currentlyPlayingSong).toEqual(song);52 });53});54describe('when song has not been paused', function() {55 it('should indicate that the song is currently playing', function() {56 player.play(song);57 expect(player.isPlaying).toBeTruthy();58 expect(player.currentlyPlayingSong).toEqual(song);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Jasmine-core automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful