Cyp*_*eon 5 android cordova ionic2 ionic3 angular
所以,我目前正在尝试通过cordova文件插件读取我刚刚保存在应用程序目录(Android)上的音频文件,但我一直得到相同的错误代码5,代表"ENCODING_ERR".
这是我创建文件并开始录制的方式
start() {
this.filename = this.file.externalDataDirectory.replace(/file:\/\//g, '');
this.mediaobject = this.media.create(this.filename + 'audioprofile' + '.3gp');
this.mediaobject.startRecord();
}
Run Code Online (Sandbox Code Playgroud)
这就是我停止录制和保存文件的方法
stop() {
this.mediaobject.stopRecord();
this.mediaobject.release();
...
Run Code Online (Sandbox Code Playgroud)
这就是我被困住的地方:保存之后,我需要把它作为一个字符串,所以我试着读它(alert(content)应该给我看一下这个字符串)
stop() {
this.mediaobject.stopRecord();
this.mediaobject.release();
this.storage.get("uid").then((id) => {
try{
this.file.readAsDataURL(this.filename,'audioprofile'+'.3gp').then((filecontent)=>{
alert(filecontent);
},(err)=>{
alert(err.code);
})
} `
Run Code Online (Sandbox Code Playgroud)
经过一些研究后我发现它可能意味着我没有为它提供正确的路径,但我已经尝试了所有内容,"filename"和"filepath"的任意组合都已经完成,甚至在start()上添加了前缀.
我想知道是否有人设法用这个cordova插件读取文件,如果你这样做,请帮助我.
在此先感谢,这是我在这里的第一篇文章\ o /(虽然我一直使用网站,但是爱你们).
| 归档时间: |
|
| 查看次数: |
311 次 |
| 最近记录: |