cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject js commit: [all] Use argscheck in Media.
Date Thu, 10 Jan 2013 14:34:44 GMT
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 <agrieve@chromium.org>
Authored: Tue Jan 8 20:23:35 2013 -0500
Committer: Andrew Grieve <agrieve@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);
     }
 
 };


Mime
View raw message