我目前正在研制一台相机,可以在我的角度应用程序中记录视频。目前,使用下面的代码,我可以访问我的相机和快照。
有人能建议我应该修改我的代码,以便有能力拍摄视频吗?
App.module.ts文件:
import {WebcamModule} from 'ngx-webcam';
...
imports: [
...
WebcamModule
]
app.component.ts文件:
import {WebcamImage} from 'ngx-webcam';
import {Subject, Observable} from 'rxjs';
...
export class AppComponent {
...
// latest snapshot
public webcamImage: WebcamImage = null;
// webcam snapshot trigger
private trigger: Subject<void> = new Subject<void>();
triggerSnapshot(): void {
this.trigger.next();
}
handleImage(webcamImage: WebcamImage): void {
console.info('received webcam image', webcamImage);
this.webcamImage = webcamImage;
}
public get triggerObservable(): Observable<void> {
return this.trigger.asObservable();
}
}
app.component.html文件:
<webcam [height]="500" [width]="500" [trigger]="triggerObservable" (imageCapture)="handleImage($event)"></webcam>
<!-- Button Takes Photo -->
<button class="actionBtn" (click)="triggerSnapshot();">Take A Snapshot</button>
<!-- Snapshot Div where image will be shown -->
<div class="snapshot" *ngIf="webcamImage">
<h2>Take your image or get another</h2>
<img [src]="webcamImage.imageAsDataUrl"/>
</div>
发布于 2020-07-17 18:41:25
ngx-摄像头还不支持开箱录音。https://github.com/basst314/ngx-webcam/issues/38的内置特性
现代操作系统(操作系统必须支持WebRTC/UserMedia )的capturing
https://stackoverflow.com/questions/62959304
复制相似问题