Skip to content

Commit 2b44787

Browse files
committed
feat(add performacne and unlock)
1 parent 1ac858e commit 2b44787

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

app/angular.audio.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,23 @@ angular.module('ngAudio', [])
9292

9393
.value('ngAudioGlobals', {
9494
muting: false,
95-
songmuting: false
95+
songmuting: false,
96+
performance: 25,
97+
unlock: true
9698
})
9799

98100
.factory('NgAudioObject', ['cleverAudioFindingService', '$rootScope', '$interval', '$timeout', 'ngAudioGlobals', function(cleverAudioFindingService, $rootScope, $interval, $timeout, ngAudioGlobals) {
99101
return function(id) {
100102

101-
window.addEventListener("click",function twiddle(){
102-
audio.play();
103-
audio.pause();
104-
window.removeEventListener("click",twiddle);
105-
});
103+
if (ngAudioGlobals.unlock) {
104+
105+
window.addEventListener("click",function twiddle(){
106+
audio.play();
107+
audio.pause();
108+
window.removeEventListener("click",twiddle);
109+
});
110+
111+
}
106112

107113

108114
var $audioWatch,
@@ -266,7 +272,7 @@ angular.module('ngAudio', [])
266272
}
267273

268274
$setWatch();
269-
}, 25);
275+
}, ngAudioGlobals.performance);
270276
};
271277
}])
272278
.service('ngAudio', ['NgAudioObject', 'ngAudioGlobals', function(NgAudioObject, ngAudioGlobals) {

app/partial/ngAudioDocs.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ <h4>ngAudio Service Reference</h4>
5151
<td>unmute()</td>
5252
<td>Globally unmutes all the sounds.</td>
5353
</tr>
54+
<tr>
55+
<td>performance : Number</td>
56+
<td>Changes the interval that Angular Audio observes the audio. A lower number here will improve responsiveness at the cost of processor power.</td>
57+
</tr>
58+
<tr>
59+
<td>unlock = true : Boolean</td>
60+
<td>If true, attempts to 'unlock' audio files so that they work on mobile devices. Disabling this can break this library in mobile!</td>
61+
</tr>
5462
</table>
5563
</article>
5664
<article>

0 commit comments

Comments
 (0)