尝试访问连接到 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);
}); …Run Code Online (Sandbox Code Playgroud)