You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by na...@apache.org on 2014/04/28 23:28:10 UTC

[26/34] git commit: CB-6411 [BlackBerry10] Work around Audio playback issue

CB-6411 [BlackBerry10] Work around Audio playback issue


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

Branch: refs/heads/dev
Commit: 66ae734492a07c5e2ccd4129db5d868fc363b82b
Parents: bd7354e
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Tue Apr 8 11:17:55 2014 -0400
Committer: Archana Naik <na...@lab126.com>
Committed: Tue Apr 15 17:48:43 2014 -0700

----------------------------------------------------------------------
 www/blackberry10/beep.js | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/66ae7344/www/blackberry10/beep.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/beep.js b/www/blackberry10/beep.js
index 1b1dedc..6605107 100644
--- a/www/blackberry10/beep.js
+++ b/www/blackberry10/beep.js
@@ -21,19 +21,22 @@
 
 module.exports = function (quantity) {
     var count = 0,
-        beepObj = new Audio('local:///chrome/plugin/org.apache.cordova.dialogs/notification-beep.wav'),
+        beepObj,
+        play = function () { 
+            //create new object every time due to strage playback behaviour
+            beepObj = new Audio('local:///chrome/plugin/org.apache.cordova.dialogs/notification-beep.wav');
+            beepObj.addEventListener("ended", callback);
+            beepObj.play();
+        },
         callback = function () {
             if (--count > 0) {
-                beepObj.play();
+                play();
             } else {
-                beepObj.removeEventListener("ended", callback);
                 delete beepObj;
             }
         };
-
     count += quantity || 1;
     if (count > 0) {
-        beepObj.addEventListener("ended", callback);
-        beepObj.play();
+        play();
     }
 };