You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/12/05 01:58:00 UTC
[4/8] git commit: added beep funtionality using
ms-winsoundevent:Notfication.Default
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/master
Commit: 94a35af385b975f77faeaf463d1801474eb63368
Parents: 20a7dc5
Author: purplecabbage <pu...@gmail.com>
Authored: Tue Nov 5 10:41:42 2013 -0800
Committer: purplecabbage <pu...@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();
+
}
};