cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject [06/34] git commit: added beep funtionality using ms-winsoundevent:Notfication.Default
Date Mon, 28 Apr 2014 21:27:50 GMT
added beep funtionality using ms-winsoundevent:Notfication.Default


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/commit/67e380e2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/67e380e2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/67e380e2

Branch: refs/heads/dev
Commit: 67e380e22efef7de41a4a5fdb6c241e482b58fb2
Parents: b80d7de
Author: purplecabbage <purplecabbage@gmail.com>
Authored: Tue Nov 5 10:41:42 2013 -0800
Committer: Archana Naik <naika@lab126.com>
Committed: Thu Mar 20 16:28:54 2014 -0700

----------------------------------------------------------------------
 src/windows8/NotificationProxy.js | 35 ++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/67e380e2/src/windows8/NotificationProxy.js
----------------------------------------------------------------------
diff --git a/src/windows8/NotificationProxy.js b/src/windows8/NotificationProxy.js
index b171064..aed72a5 100644
--- a/src/windows8/NotificationProxy.js
+++ b/src/windows8/NotificationProxy.js
@@ -93,24 +93,27 @@ module.exports = {
     },
 
     beep:function(winX, loseX, args) {
-        var count = args[0];
-        /*
-        var src = //filepath//
-        var playTime = 500; // ms
-        var quietTime = 1000; // ms
-        var media = new Media(src, function(){});
-        var hit = 1;
-        var intervalId = window.setInterval( function () {
-            media.play();
-            sleep(playTime);
-            media.stop();
-            media.seekTo(0);
-            if (hit < count) {
-                hit++;
+
+        // set a default args if it is not set
+        args = args && args.length ? args : ["1"];
+
+        var snd = new Audio('ms-winsoundevent:Notification.Default');
+        var count = parseInt(args[0]) || 1;
+        snd.msAudioCategory = "Alerts";
+
+        var onEvent = function () {
+            if (count > 0) {
+                snd.play();
             } else {
-                window.clearInterval(intervalId);
+                snd.removeEventListener("ended", onEvent);
+                snd = null;
+                winX && winX(); // notification.js just sends null, but this is future
friendly
             }
-        }, playTime + quietTime); */
+            count--;
+        };
+        snd.addEventListener("ended", onEvent);
+        onEvent();
+
     }
 };
 


Mime
View raw message