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

[5/8] 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/1e7a1229
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/1e7a1229
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/1e7a1229

Branch: refs/heads/master
Commit: 1e7a122937b23eb19167a92b0c8c7a0fb6cd2a33
Parents: 47751e8
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Tue Apr 8 11:17:55 2014 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Tue Apr 8 11:17:55 2014 -0400

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


http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/1e7a1229/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();
     }
 };