Skip to content

Commit

Permalink
feat(playback) Continous play made optional, Closes #132
Browse files Browse the repository at this point in the history
Also:
 - Redesigned request/response transformers. No longer transform by reference. Solves bugs with nested objects in models, or objects that keep an original reference throughout their lifetime
 - Added autopplyback button and saved state to user profile. QSP overrides profile parameter.
 - Add SVG icons to help address issue #97
  • Loading branch information
atruskie committed Jul 19, 2014
1 parent 061fbfc commit 5a3de5d
Show file tree
Hide file tree
Showing 11 changed files with 473 additions and 36 deletions.
19 changes: 12 additions & 7 deletions src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ var app = angular.module('baw',

'url', /* a custom uri formatter */
'bawApp.configuration', /* a mapping of all static path configurations
and a module that contains all app configuration */
and a module that contains all app configuration */

'http-auth-interceptor', /* the auth module */
'angular-auth', /* the auth module */
'rails', /* a module designed to rewrite object keys on JSON objects */

'templates-app', /* these are the precompiled templates */
'templates-common',
Expand All @@ -76,10 +79,6 @@ var app = angular.module('baw',
'audio-control',
'draggabilly',

'http-auth-interceptor', /* the auth module */
'angular-auth', /* the auth module */
'rails', /* a module designed to rewrite object keys on JSON objects */

'bawApp.accounts',
'bawApp.annotationViewer',
'bawApp.audioEvents',
Expand Down Expand Up @@ -186,18 +185,24 @@ var app = angular.module('baw',

// user profile - update user preferences when they change
var eventCallbacks = {};
eventCallbacks[ngAudioEvents.volumeChanged] = function (event, api, value) {
eventCallbacks[ngAudioEvents.volumeChanged] = function(event, api, value) {
if (api.profile.preferences.volume !== value) {
api.profile.preferences.volume = value;
api.updatePreferences();
}
};
eventCallbacks[ngAudioEvents.muteChanged] = function (event, api, value) {
eventCallbacks[ngAudioEvents.muteChanged] = function(event, api, value) {
if (api.profile.preferences.muted !== value) {
api.profile.preferences.muted = value;
api.updatePreferences();
}
};
eventCallbacks["autoPlay"] = function(event, api, value) {
if(api.profile.preferences.autoPlay !== value) {
api.profile.preferences.autoPlay = value;
api.updatePreferences();
}
};
UserProfile.listen(eventCallbacks);

// helper function for printing scope objects
Expand Down
11 changes: 10 additions & 1 deletion src/app/listen/listen.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead'])
var profileLoaded = function updateProfileSettings(event, UserProfile) {
$scope.model.audioElement.volume = UserProfile.profile.preferences.volume;
$scope.model.audioElement.muted = UserProfile.profile.preferences.muted;

$scope.model.audioElement.autoPlay = UserProfile.profile.preferences.autoPlay || $routeParams.autoPlay;
};
$scope.$on(UserProfile.eventKeys.loaded, profileLoaded);
if (UserProfile.profile && UserProfile.profile.preferences) {
Expand All @@ -104,7 +106,7 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead'])
// auto play feature
$scope.$on(ngAudioEvents.ended, function navigate(event) {

if ($scope.nextEnabled) {
if ($scope.nextEnabled && $scope.model.audioElement.autoPlay) {
console.info("Changing page to next segment...");
$scope.$apply(function() {
$location.search({autoPlay: true, start: nextStart, end: nextEnd});
Expand All @@ -114,6 +116,13 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead'])
console.warn("Continuous playback cannot continue");
}
});
$scope.$watch(function() {
return $scope.model.audioElement.autoPlay;
}, function(newValue, oldValue) {
if (UserProfile.profile && (UserProfile.profile.preferences.autoPlay !== newValue)) {
$scope.$emit("autoPlay", newValue);
}
});

/* // NOT NECESSARY - we aren't using auth keys atm */
$scope.$on('event:auth-loginRequired', function(){ Media.formatPaths($scope.model.media); });
Expand Down
8 changes: 8 additions & 0 deletions src/app/listen/listen.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ <h1 id="chunkInfo" class="row">

<volume-control model="model.audioElement" class="input-group btn-group"></volume-control>

<toggle-switch model="model.audioElement.autoPlay" disabled="disabled" mode="push-toggle" title="Enable/disable autoplay" >
<toggle-switch-state switch-state="on">
<span class="glyphicon glyphicon-play-circle"></span>
</toggle-switch-state>
<toggle-switch-state switch-state="off">
<span class="glyphicon glyphicon-play-circle"></span>
</toggle-switch-state>
</toggle-switch>

</div>

Expand Down
88 changes: 88 additions & 0 deletions src/assets/img/horizontal-grid-numbers.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
91 changes: 91 additions & 0 deletions src/assets/img/horizontal-grid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions src/assets/img/vertical-grid-numbers.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5a3de5d

Please sign in to comment.