You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/08/17 20:54:50 UTC

[17/19] js commit: Modified MediaFileProxy.js

Modified MediaFileProxy.js


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

Branch: refs/heads/master
Commit: 6d4361bad3f65de0f54414bf288ceea1a036c1e8
Parents: 0b898a5
Author: mingfeng <mi...@gmail.com>
Authored: Thu Aug 16 09:27:39 2012 +0800
Committer: mingfeng <mi...@gmail.com>
Committed: Thu Aug 16 09:27:39 2012 +0800

----------------------------------------------------------------------
 lib/win8metro/plugin/win8metro/MediaFileProxy.js |   74 ++++++++---------
 1 files changed, 33 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/6d4361ba/lib/win8metro/plugin/win8metro/MediaFileProxy.js
----------------------------------------------------------------------
diff --git a/lib/win8metro/plugin/win8metro/MediaFileProxy.js b/lib/win8metro/plugin/win8metro/MediaFileProxy.js
index de34af8..a8b0a02 100755
--- a/lib/win8metro/plugin/win8metro/MediaFileProxy.js
+++ b/lib/win8metro/plugin/win8metro/MediaFileProxy.js
@@ -2,44 +2,36 @@ var utils = require('cordova/utils'),
     File = require('cordova/plugin/File'),
     CaptureError = require('cordova/plugin/CaptureError');
 
-
-/**
- * Request capture format data for a specific file and type
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- */
-MediaFile.prototype.getFormatData = function (successCallback, errorCallback, args) {
-    var contentType = args[1];
-    Windows.Storage.StorageFile.getFileFromPathAsync(args[0]).then(function (storageFile) {
-            var mediaTypeFlag = String(contentType).split("/")[0].toLowerCase();
-            if (mediaTypeFlag === "audio") {
-                storageFile.properties.getMusicPropertiesAsync().then(function (audioProperties) {
-                    successCallback(new MediaFileData(null, audioProperties.bitrate, 0, 0, audioProperties.duration / 1000));
-                }, function () {
-                    errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
-                })
-            }
-            else if (mediaTypeFlag === "video") {
-                storageFile.properties.getVideoPropertiesAsync().then(function (videoProperties) {
-                    successCallback(new MediaFileData(null, videoProperties.bitrate, videoProperties.height, videoProperties.width, videoProperties.duration / 1000));
-                }, function () {
-                    errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
-                })
-            }
-            else if (mediaTypeFlag === "image") {
-                storageFile.properties.getImagePropertiesAsync().then(function (imageProperties) {
-                    successCallback(new MediaFileData(null, 0, imageProperties.height, imageProperties.width, 0));
-                }, function () {
-                    errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
-                })
-            }
-            else { errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)) }
-        }, function () {
-            errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
-        }
-    )
- };
-
-
-module.exports = MediaFile;
\ No newline at end of file
+module.exports = {
+	getFormatData:function (successCallback, errorCallback, args) {
+	    var contentType = args[1];
+	    Windows.Storage.StorageFile.getFileFromPathAsync(args[0]).then(function (storageFile) {
+	            var mediaTypeFlag = String(contentType).split("/")[0].toLowerCase();
+	            if (mediaTypeFlag === "audio") {
+	                storageFile.properties.getMusicPropertiesAsync().then(function (audioProperties) {
+	                    successCallback(new MediaFileData(null, audioProperties.bitrate, 0, 0, audioProperties.duration / 1000));
+	                }, function () {
+	                    errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
+	                })
+	            }
+	            else if (mediaTypeFlag === "video") {
+	                storageFile.properties.getVideoPropertiesAsync().then(function (videoProperties) {
+	                    successCallback(new MediaFileData(null, videoProperties.bitrate, videoProperties.height, videoProperties.width, videoProperties.duration / 1000));
+	                }, function () {
+	                    errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
+	                })
+	            }
+	            else if (mediaTypeFlag === "image") {
+	                storageFile.properties.getImagePropertiesAsync().then(function (imageProperties) {
+	                    successCallback(new MediaFileData(null, 0, imageProperties.height, imageProperties.width, 0));
+	                }, function () {
+	                    errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
+	                })
+	            }
+	            else { errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)) }
+	        }, function () {
+	            errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
+	        }
+	    )
+	}
+}