Windows 8 Phonegap windows 8应用程序,具有摄像头功能,导航。摄像头。getPicture()回调函数在部署时从不调用
我们使用phonegap制作了一个Win8应用程序。 该应用程序还引用了用于执行某些asyc任务的Windows运行时组件。 该应用程序有一个摄像头功能,在摄像头中调用,拍摄照片,然后在成功回调功能的屏幕上显示照片。直接从visual studio express运行时,一切都可以完美运行。当我们创建应用程序包并使用metro sideloader或powershell部署它时,就会出现问题。从未调用照相机成功回调函数。 调用相机的代码如下所示:Windows 8 Phonegap windows 8应用程序,具有摄像头功能,导航。摄像头。getPicture()回调函数在部署时从不调用,windows-8,cordova,windows-runtime,mobility,Windows 8,Cordova,Windows Runtime,Mobility,我们使用phonegap制作了一个Win8应用程序。 该应用程序还引用了用于执行某些asyc任务的Windows运行时组件。 该应用程序有一个摄像头功能,在摄像头中调用,拍摄照片,然后在成功回调功能的屏幕上显示照片。直接从visual studio express运行时,一切都可以完美运行。当我们创建应用程序包并使用metro sideloader或powershell部署它时,就会出现问题。从未调用照相机成功回调函数。 调用相机的代码如下所示: CameraService = func
CameraService = function() {
var that = {};
that.invokecamera = function(callback) {
try {
GLOBALS.callback = callback;
if (GLOBALS.Ready) {
navigator.camera.getPicture(that.onSuccess, GLOBALS.ThrowException, {
quality : 50,
saveToPhotoAlbum : true,
destinationType : Camera.DestinationType.FILE_URI
});
}
} catch (err) {
alert(err);
} finally {
}
}
that.onSuccess=function(imageURI) {
GLOBALS.ImagePath = imageURI;
GLOBALS.callback(imageURI);
}
return that;
}
好的,我解决了这里提到的问题: 要修复此问题,请参见替换的链接
Windows.Storage.StorageFolder.getFolderFromPathAsync(packageId.path).done(function (storageFolder) {
与
在cordova.js文件中。我正在使用cordova 2.4.0
更详细的例子
Windows.Storage.StorageFolder.getFolderFromPathAsync(packageId.path).done(function (storageFolder) {
storageFolder.createFileAsync(tempPhotoFileName, Windows.Storage.CreationCollisionOption.generateUniqueName).done(function (file) {
file.openAsync(Windows.Storage.FileAccessMode.readWrite).done(function (fileStream) {
Windows.Storage.Streams.RandomAccessStream.copyAndCloseAsync(_stream, fileStream).done(function () {
var _imageUrl = URL.createObjectURL(file);
successCallback(_imageUrl);
}, function () { errorCallback("Resize picture error."); });
}, function () { errorCallback("Resize picture error."); });
}, function () { errorCallback("Resize picture error."); });
});
变成
var storageFolder = Windows.Storage.ApplicationData.current.localFolder;
storageFolder.createFileAsync(tempPhotoFileName, Windows.Storage.CreationCollisionOption.generateUniqueName).done(function (file) {
file.openAsync(Windows.Storage.FileAccessMode.readWrite).done(function (fileStream) {
Windows.Storage.Streams.RandomAccessStream.copyAndCloseAsync(_stream, fileStream).done(function () {
var _imageUrl = URL.createObjectURL(file);
successCallback(_imageUrl);
}, function () { errorCallback("Resize picture error."); });
}, function () { errorCallback("Resize picture error."); });
}, function () { errorCallback("Resize picture error."); });
var storageFolder = Windows.Storage.ApplicationData.current.localFolder;
storageFolder.createFileAsync(tempPhotoFileName, Windows.Storage.CreationCollisionOption.generateUniqueName).done(function (file) {
file.openAsync(Windows.Storage.FileAccessMode.readWrite).done(function (fileStream) {
Windows.Storage.Streams.RandomAccessStream.copyAndCloseAsync(_stream, fileStream).done(function () {
var _imageUrl = URL.createObjectURL(file);
successCallback(_imageUrl);
}, function () { errorCallback("Resize picture error."); });
}, function () { errorCallback("Resize picture error."); });
}, function () { errorCallback("Resize picture error."); });