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
[7/19] js commit: Merge MediaFile with lib/common/plugin/MediaFile.js
Merge MediaFile with lib/common/plugin/MediaFile.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/42a25531
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/42a25531
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/42a25531
Branch: refs/heads/master
Commit: 42a255316e540588b6c8267e43ca6ccf52324deb
Parents: f3539f8
Author: mingfeng <mi...@gmail.com>
Authored: Fri Aug 17 11:16:32 2012 +0800
Committer: mingfeng <mi...@gmail.com>
Committed: Fri Aug 17 11:16:32 2012 +0800
----------------------------------------------------------------------
lib/win8metro/platform.js | 119 ++++++++++++----------
lib/win8metro/plugin/win8metro/MediaFile.js | 44 ++++++++
2 files changed, 107 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/42a25531/lib/win8metro/platform.js
----------------------------------------------------------------------
diff --git a/lib/win8metro/platform.js b/lib/win8metro/platform.js
old mode 100644
new mode 100755
index 54886d4..659ec3b
--- a/lib/win8metro/platform.js
+++ b/lib/win8metro/platform.js
@@ -1,57 +1,64 @@
-var cordova = require('cordova'),
- exec = require('cordova/exec'),
- channel = cordova.require("cordova/channel");
-
-module.exports = {
- id: "win8metro",
- initialize:function() {
-
- console.log("win8metro initialize");
- //window.alert = require("cordova/plugin/notification").alert;
-
- // INject a lsitener for the backbutton, and tell native to override the flag (true/false) when we have 1 or more, or 0, listeners
- // var backButtonChannel = cordova.addDocumentEventHandler('backbutton', {
- // onSubscribe:function() {
- // if (this.numHandlers === 1) {
- // exec(null, null, "CoreEvents", "overridebackbutton", [true]);
- // }
- // },
- // onUnsubscribe:function() {
- // if (this.numHandlers === 0) {
- // exec(null, null, "CoreEvents", "overridebackbutton", [false]);
- // }
- // }
- // });
-
- },
- objects: {
- navigator: {
- children: {
- device: {
- path:"cordova/plugin/win8metro/device",
- children:{
- capture:{
- path:"cordova/plugin/capture"
- }
- }
- },
- console: {
- path: "cordova/plugin/win8metro/console"
-
- },
- notification: {
- path: 'cordova/plugin/notification'
- }
- }
-
- }
- //,
- // device:{
- // path:"cordova/plugin/win8metro/device"
- // }
- // ,
- // console:{
- // path: "cordova/plugin/win8metro/console"
- // }
- }
+var cordova = require('cordova'),
+ exec = require('cordova/exec'),
+ channel = cordova.require("cordova/channel");
+
+module.exports = {
+ id: "win8metro",
+ initialize:function() {
+
+ console.log("win8metro initialize");
+ //window.alert = require("cordova/plugin/notification").alert;
+
+ // INject a lsitener for the backbutton, and tell native to override the flag (true/false) when we have 1 or more, or 0, listeners
+ // var backButtonChannel = cordova.addDocumentEventHandler('backbutton', {
+ // onSubscribe:function() {
+ // if (this.numHandlers === 1) {
+ // exec(null, null, "CoreEvents", "overridebackbutton", [true]);
+ // }
+ // },
+ // onUnsubscribe:function() {
+ // if (this.numHandlers === 0) {
+ // exec(null, null, "CoreEvents", "overridebackbutton", [false]);
+ // }
+ // }
+ // });
+
+ },
+ objects: {
+ navigator: {
+ children: {
+ device: {
+ path:"cordova/plugin/win8metro/device",
+ children:{
+ capture:{
+ path:"cordova/plugin/capture"
+ }
+ }
+ },
+ console: {
+ path: "cordova/plugin/win8metro/console"
+
+ },
+ notification: {
+ path: 'cordova/plugin/notification'
+ }
+ }
+
+ }
+ //,
+ // device:{
+ // path:"cordova/plugin/win8metro/device"
+ // }
+ // ,
+ // console:{
+ // path: "cordova/plugin/win8metro/console"
+ // }
+ },
+
+ merges: {
+ MediaFile: {
+ path: "cordova/plugin/win8metro/MediaFile"
+ }
+
+ }
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/42a25531/lib/win8metro/plugin/win8metro/MediaFile.js
----------------------------------------------------------------------
diff --git a/lib/win8metro/plugin/win8metro/MediaFile.js b/lib/win8metro/plugin/win8metro/MediaFile.js
new file mode 100755
index 0000000..f754105
--- /dev/null
+++ b/lib/win8metro/plugin/win8metro/MediaFile.js
@@ -0,0 +1,44 @@
+var MediaFileData = require('cordova/plugin/MediaFileData');
+var CaptureError = require('cordova/plugin/CaptureError');
+
+module.exports = {
+
+ getFormatData: function (successCallback, errorCallback, args) {
+ if (typeof this.fullPath === "undefined" || this.fullPath === null) {
+ errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
+ } else {
+ var contentType = this.type;
+ Windows.Storage.StorageFile.getFileFromPathAsync(this.fullPath).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));
+ }
+ )
+
+ }
+
+ }
+
+}
\ No newline at end of file