【发布时间】:2017-03-04 12:43:34
【问题描述】:
cordova (android) 刷新图库有插件吗?
使用cordova插件
cordova-plugin-media-capture捕获视频,它将视频保存到默认sdcard路径(画廊)。现在我将文件从 sdcard 路径移动到我的应用程序目录路径 (com.test.app)。
- 文件移动成功,我的应用程序和功能工作正常。
问题: 移动文件后仍有一个名为No thumbnail 的视频缩略图。当我单击缩略图时,会显示警报The file can not be reproduced 这是因为它已从图库路径移动到应用程序路径。如果我重新启动手机,则没有视频缩略图,因为它正在刷新 sdcard/图库。
我想要的是在移动文件后刷新图库。
移动文件代码
使用的插件: cordova-plugin-file
var fileURI="file:/storage/emulated/0/DCIM/Camera/VID_20161022_121221.mp4";
var newFileUri='file:///mnt/sdcard/Android/data/com.test.app/myvideo/';
var newFileName='uservideoname.mp4';
window.resolveLocalFileSystemURL(fileURI,
function (fileEntry) {
window.resolveLocalFileSystemURL(newFileUri,
function (dirEntry) {
// move the file to a new directory and rename it
fileEntry.moveTo(dirEntry, newFileName, function () {
// successfully moved
},
function (e) {
console.log(e);
});
},
function (e) {
console.log(e);
});
},
function (e){
console.log(e);
});
}
【问题讨论】:
-
看起来你需要一个插件来解决这个问题:stackoverflow.com/questions/8700256/…
-
我尝试了媒体扫描仪 github.com/peteygao/MediaScannerPlugin 和 github.com/saurabhgupta050890/Media-Refresher-Cordova 。我收到错误
Permission Denial: not allowed to send broadcast android.intent.action.MEDIA_MOUNTED -
关于那个错误 - 看起来你需要为 Android >= 4.4 重写插件:stackoverflow.com/a/24072611/4177762
-
将 Kitkat 及以上版本的 ACTION_MEDIA_MOUNTED 更改为 ACTION_MEDIA_SCANNER_SCAN_FILE 工作正常。但我的问题仍然存在。扫描后有相同的 0 字节缩略图。@daserge 感谢您的时间
标签: android jquery ios cordova video