[
https://issues.apache.org/jira/browse/CB-8054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14498286#comment-14498286
]
ASF GitHub Bot commented on CB-8054:
------------------------------------
Github user nikhilkh commented on a diff in the pull request:
https://github.com/apache/cordova-plugin-camera/pull/86#discussion_r28528079
--- Diff: src/windows/CameraProxy.js ---
@@ -134,16 +134,84 @@ function resizeImageBase64(successCallback,
errorCallback, file, targetWidth, ta
}, function(err) { errorCallback(err); });
}
-function takePictureFromFile(successCallback, errorCallback, mediaType,
destinationType, targetWidth, targetHeight, encodingType) {
- // TODO: Add WP8.1 support
- // WP8.1 doesn't allow to use of pickSingleFileAsync method
- // see
http://msdn.microsoft.com/en-us/library/windows/apps/br207852.aspx for details
- // replacement of pickSingleFileAsync - pickSingleFileAndContinue
method
- // will take application to suspended state and this require
additional logic to wake application up
- if (navigator.appVersion.indexOf('Windows Phone 8.1') >= 0 ) {
- errorCallback('Not supported');
- return;
+function takePictureFromFile(successCallback, errorCallback, args) {
+ // Detect Windows Phone
+ if (navigator.appVersion.indexOf('Windows Phone 8.1') >= 0) {
+ takePictureFromFileWP(successCallback, errorCallback, args);
+ } else {
+ takePictureFromFileWindows(successCallback, errorCallback, args);
}
+}
+
+function takePictureFromFileWP(successCallback, errorCallback, args) {
+ var mediaType = args[6],
+ destinationType = args[1],
+ targetWidth = args[3],
+ targetHeight = args[4],
+ encodingType = args[5];
+
+ /*
+ Need to add and remove an event listener to catch activation state
+ Using FileOpenPicker will suspend the app and it's required to
catch the PickSingleFileAndContinue
+
https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn631755.aspx
+ */
+ var filePickerActivationHandler = function(eventArgs) {
+ if (eventArgs.kind ===
Windows.ApplicationModel.Activation.ActivationKind.pickFileContinuation) {
+ var file = eventArgs.files[0];
+ if (!file) {
+ errorCallback("User didn't choose a file.");
+
Windows.UI.WebUI.WebUIApplication.removeEventListener("activated",
filePickerActivationHandler);
+ return;
+ }
+ if (destinationType == Camera.DestinationType.FILE_URI ||
destinationType == Camera.DestinationType.NATIVE_URI) {
+ if (targetHeight > 0 && targetWidth > 0) {
+ resizeImage(successCallback, errorCallback, file,
targetWidth, targetHeight, encodingType);
+ }
+ else {
+ var storageFolder =
Windows.Storage.ApplicationData.current.localFolder;
+ file.copyAsync(storageFolder, file.name,
Windows.Storage.NameCollisionOption.replaceExisting).done(function
(storageFile) {
+ successCallback(URL.createObjectURL(storageFile));
+ }, function () {
+ errorCallback("Can't access localStorage folder.");
+ });
+ }
+ }
+ else {
+ if (targetHeight > 0 && targetWidth > 0) {
+ resizeImageBase64(successCallback, errorCallback,
file, targetWidth, targetHeight);
+ } else {
+
Windows.Storage.FileIO.readBufferAsync(file).done(function (buffer) {
+ var strBase64 =
Windows.Security.Cryptography.CryptographicBuffer.encodeToBase64String(buffer);
+ successCallback(strBase64);
+ }, errorCallback);
+ }
+ }
+
Windows.UI.WebUI.WebUIApplication.removeEventListener("activated",
filePickerActivationHandler);
+ }
+ };
+
+ var fileOpenPicker = new Windows.Storage.Pickers.FileOpenPicker();
+ fileOpenPicker.suggestedStartLocation =
Windows.Storage.Pickers.PickerLocationId.documentsLibrary;
+ if (mediaType == Camera.MediaType.PICTURE) {
+ fileOpenPicker.fileTypeFilter.replaceAll([".png", ".jpg",
".jpeg"]);
+ }
+ else if (mediaType == Camera.MediaType.VIDEO) {
+ fileOpenPicker.fileTypeFilter.replaceAll([".avi", ".flv", ".asx",
".asf", ".mov", ".mp4", ".mpg", ".rm", ".srt", ".swf", ".wmv", ".vob"]);
--- End diff --
Wonder if this list of video formats should be shared with the one from
windows below? It's amazing that so many video formats are supported here.
> Camera getPicture photo library not supported on Windows?
> ---------------------------------------------------------
>
> Key: CB-8054
> URL: https://issues.apache.org/jira/browse/CB-8054
> Project: Apache Cordova
> Issue Type: Bug
> Components: Plugin Camera, Windows
> Affects Versions: 3.7.1
> Environment: Windows Phone 8.1
> Lumia 635
> Windows universal app platform
> Camera plugin v0.3.3
> Reporter: Boston Dell-Vandenberg
>
> On the Windows platform when calling getPicture() with "sourceType" of
> "PHOTOLIBRARY" or "SAVEDPHOTOALBUM" it returns "Not supported" error.
> The plugin documentation says Windows is supported but is that not the case?
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]