Cordova选择视频结果路径而不扩展
Cordova choose video resulting path without extension
我使用下面的代码从库中选择视频
navigator.camera.getPicture(function (data) {
callback(true, data);
},
function (e) {
callback(false, null);
}, {
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY,
mediaType: navigator.camera.MediaType.VIDEO
});
但是在回调中,我得到了以下格式的路径
content://media/external/video/media/832
如何获取原始文件路径?
我知道这有点晚了,但也许其他人需要这个(使用resolveLocalFileSystemURL然后使用toURL())检查此代码
navigator.camera.getPicture(onSuccess, onFail, {
limit: 1,
mediaType: window.Camera.MediaType.VIDEO,
destinationType: window.Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY
});
function onSuccess(fileURI) {
window.resolveLocalFileSystemURL(fileURI,
function (fileEntry) {
console.log(fileEntry.toURL());
//console.log(fileEntry.fullPath);
},
function () { });
}
function onFail(error) {
console.log(error);
}
step1添加Cordova -filepath-resolver
对于Ionic,你也可以使用:
ionic plugin add cordova-filepath-resolver
步骤2
把代码放到
function camerasucess(videourl) {
//videourl is something like this content //media/external/video
var successCallback = function (data) {
console.log(JSON.stringify(data));
//here you will get the correct path of the video file and you can upload the video file
$scope.data = data;
};
var errorCallback = function (data) {
console.log(JSON.stringify(data));
};
window.FilePath.resolveNativePath(videourl, successCallback, errorCallback);
};
function cameraError(data) {
alert(JSON.stringify(data));
};
if (navigator.camera)
{
navigator.camera.getPicture(camerasucess, cameraError, {
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY, mediaType: navigator.camera.MediaType.VIDEO,
});
}
相关文章:
- Node.js v6.2.0类扩展不是函数错误
- 扩展移相器按钮类不工作
- chrome扩展中的navigator.geolocation.getCurrentPosition
- chrome扩展:尽管运行了at:documentidle,js脚本还是过早启动
- chrome扩展更改主机/域警告
- Javascript:使用绝对路径设置img src
- 如何在Sonarqube Javascript扩展中获取项目路径
- Javascript 和/或 chrome 扩展:记住文件夹路径
- 获取通过chrome扩展程序下载的文件的绝对路径
- 扩展 SVG 路径
- 有没有办法获取谷歌浏览器扩展程序的绝对路径
- 使用相对路径时无法加载chrome扩展内容脚本
- 将文件名替换为路径和扩展名
- Angular ui路由器在路径参数后扩展url
- 当使用属性路径扩展时,registerEntityTypeCtor初始化器似乎不会触发
- Chrome扩展:以编程方式检查元素和"复制xpath"或者“复制CSS路径”
- Express res. renderbreak在使用深层url路径时扩展布局
- VS代码扩展-获取完整路径
- Cordova选择视频结果路径而不扩展
- 可以'由于安全策略的原因,不要使用Raphael JS在Chrome扩展弹出窗口中绘制路径