captureDemo/src/app/home/home.page.ts
2021-10-01 15:58:53 +08:00

38 lines
892 B
TypeScript

import { Component, NgZone } from '@angular/core';
import { WebView } from '@ionic-native/ionic-webview/ngx';
declare const capture: any;
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
data: any = {};
video: any = {
ready: false,
};
constructor(private ngZone: NgZone, private webView: WebView) { }
record() {
capture.capture('',
(rst: any) => {
console.log(rst);
this.ngZone.run(() => {
this.data = rst;
if (!rst.cancelled) {
this.video.url = this.webView.convertFileSrc(rst.video);
this.video.thumbnail = this.webView.convertFileSrc(rst.thumbnail);
this.video.ready = true;
}
});
},
(err: any) => {
console.log(err);
alert(JSON.stringify(err));
});
}
}