Skip to content

Commit

Permalink
status check
Browse files Browse the repository at this point in the history
  • Loading branch information
yoavz committed Nov 23, 2014
1 parent 4eb0673 commit 96bf924
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
18 changes: 12 additions & 6 deletions app/controllers/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ app.controller('januController', ['$scope','$http','$interval','$timeout', funct

// start the timer
$interval(function(){
console.log($scope.roundActive);
timeLeft = getTimeLeft();
if(timeLeft<16){
$scope.timeLeft = timeLeft;
Expand All @@ -49,7 +50,7 @@ app.controller('januController', ['$scope','$http','$interval','$timeout', funct
if (timeLeft <= 0) {
$('#album-cover').removeClass('animate-blur');
$('#album-cover').removeClass('no-blur');
if ($scope.roundActive) {
if ($scope.roundActive && !musicLoading()) {
$scope.roundActive = false;
checkAnswer();
}
Expand Down Expand Up @@ -80,6 +81,9 @@ app.controller('januController', ['$scope','$http','$interval','$timeout', funct
}

$scope.placeMarker = function () {
if (!$scope.roundActive)
return;

index = markerIndex();

//if it's the final span, then represent as -1
Expand Down Expand Up @@ -176,11 +180,13 @@ app.controller('januController', ['$scope','$http','$interval','$timeout', funct
//clear the selection
$scope.currentAnswer = null;

newSong = fetchNewSong();
playSong(newSong);
$scope.markerSet = false;
$scope.score.round = 0;
$scope.roundActive = true;
setTimeout(function () {
newSong = fetchNewSong();
playSong(newSong);
$scope.markerSet = false;
$scope.score.round = 0;
$scope.roundActive = true;
}, 3000);
}

function answerSuccess() {
Expand Down
10 changes: 5 additions & 5 deletions scripts/musicPlayer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
var audio = new Audio();
audio.loading = false;
var TIME_PER_SONG = 20.0;
var TIME_BETWEEN_ROUNDS = 5.0;
var TIME_PER_ROUND = TIME_PER_SONG - TIME_BETWEEN_ROUNDS;

function playSong(song){
audio.loading = true;
previewURL(song.song_id, function (preview_url) {
audio.src = preview_url;
var skipped = false;
Expand All @@ -14,6 +16,7 @@ function playSong(song){
}
});
audio.play();
audio.loading = false;
});
}

Expand All @@ -38,9 +41,6 @@ function getTimeLeft() {
}
}

function isPlaying() {
if (audio.duration)
return true;
else
return false;
function musicLoading() {
return audio.loading;
}

0 comments on commit 96bf924

Please sign in to comment.