Skip to content

Commit

Permalink
fix(citizenScienceExamples): fixed bug where ended event from example…
Browse files Browse the repository at this point in the history
…s audio caused navigation to next sample
  • Loading branch information
peichins committed Feb 16, 2017
1 parent 8adbdab commit 0eb30eb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
19 changes: 12 additions & 7 deletions src/app/citizenScience/bristlebird/bristlebird.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ class BristlebirdController {

this.showAudio = CitizenScienceCommon.bindShowAudio($scope);





/**
* Sets the current sample to sampleNum
* @param sample_num int the index of the samples array of json objects
Expand Down Expand Up @@ -126,14 +130,15 @@ class BristlebirdController {
/**
* auto play feature
* when the playback arrives at the end of the audio, it will proceed to the next segment.
* @TODO: fix bug where it goes to the next segment at the end of a label example
*/
$scope.$on(ngAudioEvents.ended, function navigate(event) {
var nextSampleNum = $scope.currentSampleNum + 1;
console.info("Changing page to next segment, which is segment " + nextSampleNum);
$scope.$safeApply($scope, function () {
$scope.goToSample(nextSampleNum);
});
$scope.$on(ngAudioEvents.ended, function navigate(event, model) {
if (model === $scope.model.audioElement) {
var nextSampleNum = $scope.currentSampleNum + 1;
console.info("Changing page to next segment, which is segment " + nextSampleNum);
$scope.$safeApply($scope, function () {
$scope.goToSample(nextSampleNum);
});
}
});
}

Expand Down
9 changes: 5 additions & 4 deletions src/app/citizenScience/examples/_examples.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

.examples-container {
text-align: center;
margin-top: 10px;
}


Expand All @@ -11,11 +12,11 @@
padding: 8px;
min-width: 410px;

background: #ffffff;
background: rgba(255,255,255,0.9);
border-radius: 5px;
-webkit-box-shadow: 3x 3px 5px rgba(0,0,0,0.3);
-moz-box-shadow: 3x 3px 5px rgba(0,0,0,0.3);
box-shadow: 3x 3px 5px rgba(0,0,0,0.3);
-webkit-box-shadow: 3px 3px 5px rgba(0,0,0,0.3);
-moz-box-shadow: 3px 3px 5px rgba(0,0,0,0.3);
box-shadow: 3px 3px 5px rgba(0,0,0,0.3);


&.selected {
Expand Down
2 changes: 1 addition & 1 deletion src/components/directives/ngAudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ angular.module("bawApp.directives.ngAudio", [
updateState(event);

console.debug("ngAudio:audioEvent:ended");
scope.$emit(ngAudioEvents.ended, null);
scope.$emit(ngAudioEvents.ended, target);
},
"error": function (event) {
console.error("ngAudio:audioElement:errorEvent", event);
Expand Down

0 comments on commit 0eb30eb

Please sign in to comment.