move MediaFile.getFormatData to CaptureProxy

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/570068c0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/570068c0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/570068c0

Branch: refs/heads/master
Commit: 570068c0fc482fe709792b51e047919327292113
Parents: 8e95d9e
Author: mingfeng <mingfengwan...@gmail.com>
Authored: Thu Aug 16 16:24:34 2012 +0800
Committer: mingfeng <mingfengwan...@gmail.com>
Committed: Thu Aug 16 16:24:34 2012 +0800

----------------------------------------------------------------------
 lib/win8metro/exec.js                            |    1 -
 lib/win8metro/plugin/win8metro/CaptureProxy.js   |   38 ++++++++++++++++-
 lib/win8metro/plugin/win8metro/MediaFileProxy.js |   38 -----------------
 3 files changed, 37 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/570068c0/lib/win8metro/exec.js
----------------------------------------------------------------------
diff --git a/lib/win8metro/exec.js b/lib/win8metro/exec.js
index db3f098..e05c1e7 100644
--- a/lib/win8metro/exec.js
+++ b/lib/win8metro/exec.js
@@ -34,7 +34,6 @@ var CommandProxy  = {
     "Device":require('cordova/plugin/win8metro/DeviceProxy'),
     "File":require('cordova/plugin/win8metro/FileProxy'),
     "Media":require('cordova/plugin/win8metro/MediaProxy'),
-    "MediaFile":require('cordova/plugin/win8metro/MediaFileProxy'),
     "NetworkStatus":require('cordova/plugin/win8metro/NetworkStatusProxy'),
     "Notification":require('cordova/plugin/win8metro/NotificationProxy')
 };

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/570068c0/lib/win8metro/plugin/win8metro/CaptureProxy.js
----------------------------------------------------------------------
diff --git a/lib/win8metro/plugin/win8metro/CaptureProxy.js 
b/lib/win8metro/plugin/win8metro/CaptureProxy.js
index 1cb1dfe..1c2e509 100755
--- a/lib/win8metro/plugin/win8metro/CaptureProxy.js
+++ b/lib/win8metro/plugin/win8metro/CaptureProxy.js
@@ -3,6 +3,7 @@ var CaptureError = require('cordova/plugin/CaptureError');
 var CaptureAudioOptions = require('cordova/plugin/CaptureAudioOptions');
 var CaptureImageOptions = require('cordova/plugin/CaptureImageOptions');
 var CaptureVideoOptions = require('cordova/plugin/CaptureVideoOptions');
+var MediaFileData = require('cordova/plugin/MediaFileData');
 
 module.exports = {
     
@@ -10,6 +11,7 @@ module.exports = {
     cameraCaptureAudioDuration: null,
 
     captureAudio:function(successCallback, errorCallback, options) {
+               var options = options[0];
         var audioOptions = new CaptureAudioOptions();
         if (options.duration && options.duration > 0) {
             audioOptions.duration = options.duration;
@@ -46,6 +48,7 @@ module.exports = {
     },
 
     captureImage:function (successCallback, errorCallback, options) {
+               var options = options[0];
         var imageOptions = new CaptureImageOptions();
         var cameraCaptureUI = new Windows.Media.Capture.CameraCaptureUI();
         cameraCaptureUI.photoSettings.allowCropping = true;
@@ -65,6 +68,7 @@ module.exports = {
     },
 
     captureVideo:function (successCallback, errorCallback, options) {
+               var options = options[0];
         var videoOptions = new CaptureVideoOptions();
         if (options.duration && options.duration > 0) {
             videoOptions.duration = options.duration;
@@ -88,5 +92,37 @@ module.exports = {
             });
         }, function () { errorCallback(new 
CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); })
     
-    }
+    },
+       
+       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));
+               }
+           )
+       }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/570068c0/lib/win8metro/plugin/win8metro/MediaFileProxy.js
----------------------------------------------------------------------
diff --git a/lib/win8metro/plugin/win8metro/MediaFileProxy.js 
b/lib/win8metro/plugin/win8metro/MediaFileProxy.js
deleted file mode 100755
index 18bc826..0000000
--- a/lib/win8metro/plugin/win8metro/MediaFileProxy.js
+++ /dev/null
@@ -1,38 +0,0 @@
-var utils = require('cordova/utils'),
-    File = require('cordova/plugin/File'),
-    CaptureError = require('cordova/plugin/CaptureError');
-    MediaFileData = require('cordova/plugin/MediaFileData');
-
-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));
-               }
-           )
-       }
-}

Reply via email to