我无法使用steroid.js访问文件系统。我在phonegap中使用了完全相同的代码,没有这个问题。以下是我的代码,在我的控制台中似乎没有得到任何错误。
var captureSuccess = function(mediaFiles) {
mediaFiles[0].getFormatData(function(data) {
if(data.duration > 10) {
window.resolveLocalFileSystemURI(mediaFiles[0].fullPath, FileRemoveSuccess, function() {
navigator.notification.alert('Error: Unable to access file system')
});
}
else{
$('#video-content').append('<video width="320" height="240" controls><source src="' + mediaFiles[0].fullPath + '" type="video/mp4"></video><br><span>' + mediaFiles[0].fullPath + '</span>');
}
});
};
// capture error callback
var captureError = function(error) {
navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
};
// start video capture
function RecordVideo(){
navigator.device.capture.captureVideo(captureSuccess, captureError, {duration:10});
}我也曾尝试通过手动输入路径或视频来访问图像,但我也遇到了同样的问题。我是不是漏掉了什么?
发布于 2013-10-15 21:03:07
如果你通过本地主机(例如steroids.config.location = http://localhost/index.html )为你的应用程序提供服务,那么内置的WebKit安全将阻止来自file:///的资产,因为它在不同的域中。真的是这样吗?我们正在努力为所有CORS问题提供解决方案,但请参阅http://guides.appgyver.com/steroids/guides/steroids-js/app-structure-on-device/了解有关如何在设备上构建类固醇应用程序的信息(以及如何通过本地主机访问文件)。
发布于 2013-10-15 21:57:02
事实证明,不仅您的index.html文件需要作为文件提供,您使用new steroids.views.WebView命令创建的任何其他not视图也是如此。一旦我纠正了这个问题,问题就解决了。
https://stackoverflow.com/questions/19350215
复制相似问题