Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 第二次录制后,IONIC 3录制音频不工作_Typescript_Ionic3 - Fatal编程技术网

Typescript 第二次录制后,IONIC 3录制音频不工作

Typescript 第二次录制后,IONIC 3录制音频不工作,typescript,ionic3,Typescript,Ionic3,在我在Ionic 3上的应用程序中,我使用媒体和MediaObject从“@Ionic native/Media”录制音频,这样可以录制和播放音频,但在录制一个音频后,MediaObject.startRecording不会返回错误并创建音频文件,但当我播放该文件时,不会播放音频。 下面是我的.ts代码 //这是我的变量: 私有记录:布尔值=false; private-recordingIco:string='assets/img/micico.png'; 私有文件路径:字符串; 私有文件名

在我在Ionic 3上的应用程序中,我使用媒体和MediaObject从“@Ionic native/Media”录制音频,这样可以录制和播放音频,但在录制一个音频后,MediaObject.startRecording不会返回错误并创建音频文件,但当我播放该文件时,不会播放音频。 下面是我的.ts代码

//这是我的变量:
私有记录:布尔值=false;
private-recordingIco:string='assets/img/micico.png';
私有文件路径:字符串;
私有文件名:字符串;
私有音频:MediaObject;
音频列表:任意[]=[];
public recordingMessage=“等待记录…”
公共媒体文件密钥='mediaFiles';
私有音频URI:任何;
私有音频文件名:任意;
私有isPlay:boolean=false;
私有audioIco:string='assets/img/playico.png';
//这是我的构造器:
构造函数(公共navCtrl:NavController,公共navParams:navParams,公共http:http,私有媒体:媒体,私有文件:文件,公共平台:平台,私有媒体捕获:媒体捕获,私有存储:存储,私有传输:文件传输){}
//这是我的录制和播放功能:
startRecord(){
let audioRec:MediaObject;
this.recordingMessage=“设备正在准备录制…”;
if(this.platform.is('ios')){
this.fileName='record'+new Date().getDate()+new Date().getMonth()+new Date().getFullYear()+new Date().getHours()+new Date().getMinutes()+new Date().getSeconds()+'.3gp';
this.filePath=this.file.dataDirectory+this.fileName;
this.audio=this.media.create(this.filePath);
}else if(this.platform.is('android')){
this.fileName='record'+new Date().getDate()+new Date().getMonth()+new Date().getFullYear()+new Date().getHours()+new Date().getMinutes()+new Date().getSeconds()+'.3gp';
this.filePath=this.file.dataDirectory+this.fileName;
this.audio=this.media.create(this.filePath);
console.log(“记录文件=“+this.filePath”);
}
日志(“开始录制…”);
这个.audio.startRecord();
日志(“录制已开始…”);
this.recordingMessage=“设备正在录制…”;
这是真的;
}
停止记录(){
this.audio.stopRecord();
日志(“记录已停止…”);
this.recordingMessage=“录制已结束…”;
让数据={filename:this.filename};
这个.audioList.push(数据);
setItem(“audiolist”,JSON.stringify(this.audiolist));
此项记录=错误;
}
播放音频(){
if(this.platform.is('ios')){
this.filePath=this.file.dataDirectory+this.fileName;
this.audio=this.media.create(this.filePath);
}else if(this.platform.is('android')){
this.filePath=this.file.dataDirectory+this.fileName;
this.audio=this.media.create(this.filePath);
}
这个.audio.play();
此.audio.setVolume(0.8);
log(“设备正在播放音频…”);
this.recordingMessage=“设备正在播放音频…”;

}
您的实际问题是什么?你希望发生什么?我的问题是关于第二次录音后不播放音频的录音。我认为问题在于媒体对象的实例或插件上的bug,或者其他原因。谢谢你的反应。