我一直在尝试使用ionics MediaCapture api来录制视频。到目前为止,我无法使其发挥作用。我得到的是{"code":20}
错误,该错误打印在catch
函数的captureVideo
中。
这是我的代码:
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { NavController } from 'ionic-angular';
import { MediaCapture, MediaFile, CaptureError, CaptureVideoOptions } from '@ionic-native/media-capture';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
plat: Platform;
constructor(platform: Platform, public navCtrl: NavController, private mediaCapture: MediaCapture) {
this.plat = platform;
}
startRecording() {
let _self = this;
let options: CaptureVideoOptions = { limit: 3 };
this.plat.ready().then(() => {
_self.mediaCapture.captureVideo(options)
.then((data: MediaFile[]) => {
console.log(data)
}).catch((err: CaptureError) => {
console.error(JSON.stringify(err));
});
}).catch((err) => {
console.log(JSON.stringify(err));
});
}
}
我使用ionic cordova emulate ios -l -c
运行它,它会打开iOS v11.2的iOS模拟器。知道我为什么会收到这个错误吗?