You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/01/10 15:34:44 UTC

js commit: [all] Use argscheck in Media.

Updated Branches:
  refs/heads/master 0e28f8266 -> 790e28572


[all] Use argscheck in Media.

Also removed unnessessary guard against console not being defined.


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/790e2857
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/790e2857
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/790e2857

Branch: refs/heads/master
Commit: 790e28572ec70d2956f24c48591ed681ddec5eaf
Parents: 0e28f82
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jan 8 20:23:35 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Jan 10 09:34:41 2013 -0500

----------------------------------------------------------------------
 lib/common/plugin/Media.js |   27 +++++----------------------
 1 files changed, 5 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/790e2857/lib/common/plugin/Media.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/Media.js b/lib/common/plugin/Media.js
index d126ace..083af36 100644
--- a/lib/common/plugin/Media.js
+++ b/lib/common/plugin/Media.js
@@ -19,7 +19,8 @@
  *
 */
 
-var utils = require('cordova/utils'),
+var argscheck = require('cordova/argscheck'),
+    utils = require('cordova/utils'),
     exec = require('cordova/exec');
 
 var mediaObjects = {};
@@ -37,25 +38,7 @@ var mediaObjects = {};
  *                                  statusCallback(int statusCode) - OPTIONAL
  */
 var Media = function(src, successCallback, errorCallback, statusCallback) {
-
-    // successCallback optional
-    if (successCallback && (typeof successCallback !== "function")) {
-        console.log("Media Error: successCallback is not a function");
-        return;
-    }
-
-    // errorCallback optional
-    if (errorCallback && (typeof errorCallback !== "function")) {
-        console.log("Media Error: errorCallback is not a function");
-        return;
-    }
-
-    // statusCallback optional
-    if (statusCallback && (typeof statusCallback !== "function")) {
-        console.log("Media Error: statusCallback is not a function");
-        return;
-    }
-
+    argscheck.checkArgs('SFFF', 'Media', arguments);
     this.id = utils.createUUID();
     mediaObjects[this.id] = this;
     this.src = src;
@@ -199,12 +182,12 @@ Media.onStatus = function(id, msgType, value) {
                 media._position = Number(value);
                 break;
             default :
-                console && console.error && console.error("Unhandled Media.onStatus :: " + msgType);
+                console.error && console.error("Unhandled Media.onStatus :: " + msgType);
                 break;
         }
     }
     else {
-         console && console.error && console.error("Received Media.onStatus callback for unknown media :: " + id);
+         console.error && console.error("Received Media.onStatus callback for unknown media :: " + id);
     }
 
 };