You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2013/01/30 00:17:26 UTC
[1/2] js commit: [CB-2287] - fix for checking that the audio.src are
defined in the right places
[CB-2287] - fix for checking that the audio.src are defined in the right places
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/271ffcdc
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/271ffcdc
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/271ffcdc
Branch: refs/heads/bb_media_fix
Commit: 271ffcdcfc51503cb8672d33850d0d935d4acafd
Parents: dd45b30
Author: Tim Kim <ti...@adobe.com>
Authored: Mon Jan 28 18:22:34 2013 -0800
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Jan 28 18:22:34 2013 -0800
----------------------------------------------------------------------
lib/blackberry/plugin/webworks/media.js | 32 +++++++++++++++++---------
1 files changed, 21 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/271ffcdc/lib/blackberry/plugin/webworks/media.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/webworks/media.js b/lib/blackberry/plugin/webworks/media.js
index 62c2b1c..a6179b4 100644
--- a/lib/blackberry/plugin/webworks/media.js
+++ b/lib/blackberry/plugin/webworks/media.js
@@ -30,8 +30,13 @@ module.exports = {
var id = args[0],
src = args[1];
+
+ if (typeof src == "undefined"){
+ audioObjects[id] = new Audio();
+ } else {
+ audioObjects[id] = new Audio(src);
+ }
- audioObjects[id] = new Audio(src);
return {"status" : 1, "message" : "Audio object created" };
},
startPlayingAudio: function (args, win, fail) {
@@ -43,19 +48,22 @@ module.exports = {
audio = audioObjects[id],
result;
- if (args.length === 1) {
+ if (args.length === 1 || typeof args[1] == "undefined" ) {
return {"status" : 9, "message" : "Media source argument not found"};
}
- if (audio) {
- audio.pause();
- audioObjects[id] = undefined;
+ if (audio.readyState !== 0){
+ if (audio) {
+ audio.pause();
+ audioObjects[id] = undefined;
+ }
+
+ audio = audioObjects[id] = new Audio(args[1]);
+ audio.play();
+ return {"status" : 1, "message" : "Audio play started" };
+ }else{
+ return {"status" : 9, "message" : "Media not ready"};
}
-
- audio = audioObjects[id] = new Audio(args[1]);
- audio.play();
-
- return {"status" : 1, "message" : "Audio play started" };
},
stopPlayingAudio: function (args, win, fail) {
if (!args.length) {
@@ -171,8 +179,10 @@ module.exports = {
result;
if (audio) {
+ if(audio.src !== ""){
+ audio.src = undefined;
+ }
audioObjects[id] = undefined;
- audio.src = undefined;
//delete audio;
}