You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2013/06/26 00:18:21 UTC
git commit: [CB-4006] Handle loop count parameter for beep
Updated Branches:
refs/heads/master 5db12530f -> 20a3e4458
[CB-4006] Handle loop count parameter for beep
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/commit/20a3e445
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/tree/20a3e445
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/diff/20a3e445
Branch: refs/heads/master
Commit: 20a3e4458f0877dfbdfb91bcd14be7aa854eaef3
Parents: 5db1253
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue Jun 25 15:18:13 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue Jun 25 15:18:13 2013 -0700
----------------------------------------------------------------------
src/ios/CDVNotification.m | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/20a3e445/src/ios/CDVNotification.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVNotification.m b/src/ios/CDVNotification.m
index 0f83304..9f0a59b 100644
--- a/src/ios/CDVNotification.m
+++ b/src/ios/CDVNotification.m
@@ -19,6 +19,7 @@
#import "CDVNotification.h"
#import <Cordova/NSDictionary+Extensions.h>
+#import <Cordova/NSArray+Comparisons.h>
#define DIALOG_TYPE_ALERT @"alert"
#define DIALOG_TYPE_PROMPT @"prompt"
@@ -121,12 +122,27 @@
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}
-- (void)beep:(CDVInvokedUrlCommand*)command
-{
+static void playBeep(int count) {
SystemSoundID completeSound;
- NSURL *audioPath = [[NSBundle mainBundle] URLForResource:@"CDVNotification.bundle/beep" withExtension:@"wav"];
+ NSURL* audioPath = [[NSBundle mainBundle] URLForResource:@"CDVNotification.bundle/beep" withExtension:@"wav"];
AudioServicesCreateSystemSoundID((CFURLRef)audioPath, &completeSound);
- AudioServicesPlaySystemSound (completeSound);
+ AudioServicesAddSystemSoundCompletion(completeSound, NULL, NULL, soundCompletionCallback, (void*)(count-1));
+ AudioServicesPlaySystemSound(completeSound);
+}
+
+static void soundCompletionCallback(SystemSoundID ssid, void* data) {
+ int count = (int)data;
+ AudioServicesRemoveSystemSoundCompletion (ssid);
+ AudioServicesDisposeSystemSoundID(ssid);
+ if (count > 0) {
+ playBeep(count);
+ }
+}
+
+- (void)beep:(CDVInvokedUrlCommand*)command
+{
+ NSNumber* count = [command.arguments objectAtIndex:0 withDefault:[NSNumber numberWithInt:1]];
+ playBeep([count intValue]);
}