尝试访问连接到 wifi 的网络摄像机。
我已连接到该 wifi,但出现错误。如果我尝试使用 vlc 打开,我可以连接但 getUserMedia 没有空值。
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
})
export class HomeComponent {
@ViewChild('video') video: any;
constructor() {
}
hasGetUserMedia() {
return !!(navigator.mediaDevices &&
navigator.mediaDevices.getUserMedia);
}
ngAfterViewInit() {
if (this.hasGetUserMedia()) {
// Good to go!
console.log("Gooddd................");
} else {
alert('getUserMedia() is not supported by your browser');
}
let _video = this.video.nativeElement;
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia({ video: true, audio: true })
.then(function (stream) {
_video.src = window.URL.createObjectURL(stream);
_video.play();
}).catch(function (err) {
console.log(err);
});
}
}
}
<video #video width="640" height="480" autoplay></video>
原文由 UI_Dev 发布,翻译遵循 CC BY-SA 4.0 许可协议
当您没有任何设备来捕获视频或捕获音频时,就会发生这种情况
尝试检查您的网络摄像头和麦克风是否工作正常