cordova - 在ionic的相机预览插件的stopRecordVideo()函数返回的文件路径上找不到视频
问题描述
当我stopRecordVideo()
在 ionic 中调用相机预览插件时,在返回的文件路径上查找录制的视频文件时遇到问题。
我使用的功能:
开始录制
startRecording(){
options = {
cameraDirection: this.cameraPreview.CAMERA_DIRECTION.BACK,
width: (window.screen.width / 2),
height: (window.screen.height / 2),
quality: 60,
withFlash: false,
storeToFile: true,
}
this.cameraPreview.startRecordVideo(options);
}
停止录制
this.cameraPreview.stopRecordVideo().then((filePath) => {
alert(JSON.stringify(filePath));
//filePath = "/data/user/0/com.xyz.abc/cache/fileName.mp4
});
我没有在该位置获取此文件。我正在使用这个插件:https ://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview 请帮我获取文件。
解决方案
我通过以下方法访问了视频文件:
import { File,FileEntry } from '@ionic-native/file/ngx';
constructor(
private file: File,
) { }
this.file.resolveLocalFilesystemUrl("file:///data/user/0/com.xyz.abc/cache/fileName.mp4")
.then(entry => {
(<FileEntry>entry).file(file => {
alert(JSON.stringify(file));
}
);
})
.catch(err => {
alert('Error while reading file.' + JSON.stringify(err));
});
推荐阅读
- android - 如果有人使用 url snooper 或 whireshark,试图从我的 android 应用程序中隐藏域
- python - 使用 pandas HTML 从网站读取和打印数据
- prolog - 有什么方法可以检查输入 n 是否小于或等于列表的长度?
- .htaccess - htaccess 重定向 301 带有非友好尾部的友好链接
- java - Scala、Akka-Http 和 mysql - 太慢了
- elasticsearch - 使用 ElasticSearch 混合用户数据
- java - 将 csv / xml 文件映射到 java 对象
- java - 重定位节点 JavaFX
- c++ - 如何在屏幕上显示对象列表?
- javascript - EventListener 在某些功能之前不起作用