Skip to content

Commit

Permalink
Fixed a bug that meant the audio element never emitted events
Browse files Browse the repository at this point in the history
  • Loading branch information
atruskie committed Feb 4, 2014
1 parent 7bde365 commit 3cd39c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,17 @@ var app = angular.module('baw',

// user profile - update user preferences when they change
var eventCallbacks = {};
eventCallbacks[ngAudioEvents.volumeChanged] = function(event, api, value) {
api.profile.preferences.volume = value;
api.updatePreferences();
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) {
api.profile.preferences.muted = value;
api.updatePreferences();
eventCallbacks[ngAudioEvents.muteChanged] = function (event, api, value) {
if (api.profile.preferences.muted !== value) {
api.profile.preferences.muted = value;
api.updatePreferences();
}
};
UserProfile.listen(eventCallbacks);

Expand Down
4 changes: 2 additions & 2 deletions src/components/directives/ngAudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ ngAudio.directive("ngAudio", ["ngAudioEvents", "$parse", function (ngAudioEvents

target.currentState = event && event.type || 'unknown';

if (target.volume != null && target.volume !== element.volume) {
if (target.volume != null) {
target.volume = element.volume;
scope.$emit(ngAudioEvents.volumeChanged, element.volume);
}

if (target.muted != null && target.muted !== element.muted) {
if (target.muted != null) {
target.muted = element.muted;
scope.$emit(ngAudioEvents.muteChanged, element.muted);
}
Expand Down

0 comments on commit 3cd39c4

Please sign in to comment.