cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject git commit: added beep funtionality using ms-winsoundevent:Notfication.Default
Date Tue, 05 Nov 2013 18:42:07 GMT
Updated Branches:
  refs/heads/dev 20a7dc556 -> 94a35af38


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/94a35af3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/94a35af3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/94a35af3

Branch: refs/heads/dev
Commit: 94a35af385b975f77faeaf463d1801474eb63368
Parents: 20a7dc5
Author: purplecabbage <purplecabbage@gmail.com>
Authored: Tue Nov 5 10:41:42 2013 -0800
Committer: purplecabbage <purplecabbage@gmail.com>
Committed: Tue Nov 5 10:41:42 2013 -0800

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


http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/94a35af3/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