cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sgreb...@apache.org
Subject [1/2] cordova-plugin-media git commit: CB-9237 Add cdvfile:// support to media plugin on windows platform
Date Tue, 04 Aug 2015 14:13:57 GMT
Repository: cordova-plugin-media
Updated Branches:
  refs/heads/master 5f8738c52 -> b992df38d


CB-9237 Add cdvfile:// support to media plugin on windows platform

Mentioned cdvfile support in the documentation


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/commit/b992df38
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/tree/b992df38
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/diff/b992df38

Branch: refs/heads/master
Commit: b992df38da74d7abc67bde3615edce034003c98f
Parents: 8cf9a96
Author: daserge <daserge@yandex.ru>
Authored: Mon Aug 3 18:28:06 2015 +0300
Committer: sgrebnov <v-segreb@microsoft.com>
Committed: Tue Aug 4 17:13:48 2015 +0300

----------------------------------------------------------------------
 README.md                 |  5 +++++
 src/windows/MediaProxy.js | 23 +++++++++++++++++++++++
 2 files changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/b992df38/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 3789f12..20403d3 100644
--- a/README.md
+++ b/README.md
@@ -73,6 +73,11 @@ Although in the global scope, it is not available until after the `deviceready`
 
 - __mediaStatus__: (Optional) The callback that executes to indicate status changes. _(Function)_
 
+__NOTE__: `cdvfile` path is supported as `src` parameter:
+```javascript
+var my_media = new Media('cdvfile://localhost/temporary/recording.mp3', ...);
+```
+
 ### Constants
 
 The following constants are reported as the only parameter to the

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/b992df38/src/windows/MediaProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/MediaProxy.js b/src/windows/MediaProxy.js
index 6806dd6..f85c5cb 100644
--- a/src/windows/MediaProxy.js
+++ b/src/windows/MediaProxy.js
@@ -326,6 +326,28 @@ function fullPathToAppData(uri) {
 }
 
 /**
+ * Converts cdvfile paths to ms-appdata path
+ * @param  {Object} uri Input cdvfile scheme Windows.Foundation.Uri
+ * @return {Object}     Windows.Foundation.Uri based on App data path
+ */
+function cdvfileToAppData(uri) {
+    var cdvFsRoot;
+
+    if (uri.schemeName === 'cdvfile') {
+        cdvFsRoot = uri.path.split('/')[1];
+        if (cdvFsRoot === 'temporary') {
+            return new Windows.Foundation.Uri(tempFolderAppDataBasePath, uri.path.split('/').slice(2).join('/'));
+        } else if (cdvFsRoot === 'persistent') {
+            return new Windows.Foundation.Uri(localFolderAppDataBasePath, uri.path.split('/').slice(2).join('/'));
+        } else {
+            throw new Error(cdvFsRoot + ' cdvfile root is not supported on Windows');
+        }
+    }
+
+    return uri;
+}
+
+/**
  * Prepares media src for internal usage
  * @param  {String} src Input media path
  * @return {Object}     Windows.Foundation.Uri
@@ -340,6 +362,7 @@ function processUri(src) {
     var uri = setTemporaryFsByDefault(src);
 
     uri = fullPathToAppData(uri);
+    uri = cdvfileToAppData(uri);
 
     return uri;
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message