不存在。
我正在尝试将新属性推向创建的对象,但是当我这样做时,我会发现"属性推动在Mediaplugin上不存在"。
import { File } from 'ionic-native'
import { MediaPlugin } from 'ionic-native';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
public total;
constructor(public navCtrl: NavController,
public alertCtrl: AlertController,
) {
}
media: MediaPlugin = new MediaPlugin("Vanan/audio.mp3");
startRecording() {
try {
this.AudioFolderCreation();
console.log("Audio folder created");
this.starttime()
this.media.startRecord();
this.status = false;
console.log("media recording" + JSON.stringify(this.media));
}
catch (e) {
this.showAlert('Could not start recording.');
}
}
stopRecording() {
try {
this.media.stopRecord();
this.status = true;
this.reset()
console.log("Recording stopped Duration is:",this.media);
console.log("media recording" ,this.media + this.total);
var obj = this.total;
this.media.push(obj);
this.presentPrompt();
}
catch (e) {
this.showAlert('Could not stop recording.');
}
}
/* Stopwatch */
starttime(){
console.log("timer started");
if( this.running == 0){
this.running = 1;
this.adder()
}else{
this.running = 0;
}
}
reset(){
console.log("timer reset");
this.running = 0;
this.time = 0;
this.total = 0;
this.Sec = 0;
}
adder(){
console.log("timer incrementor");
if(this.running == 1){
setTimeout(()=>{
this.time++;
var mins = Math.floor(this.time/10/60);
var sec = Math.floor(this.time / 10 );
var tens = this.time/10;
this.total = mins + ':' + sec ;
this.Sec = sec;
this.adder()
},100)
}
}
计时器在媒体启动并停止时开始,我需要将该值附加到创建的媒体对象,但是当我尝试它时,错误会出现媒体上不存在属性推动
不确定为什么需要添加此属性,但这应该解决您的错误
媒体:any = new MediaPlugin(" vanan/audio.mp3");