小编UI_*_*Dev的帖子

DOMException:未找到请求的设备 GetUserMedia

尝试访问连接到 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)

javascript webrtc

8
推荐指数
3
解决办法
4万
查看次数

标签 统计

javascript ×1

webrtc ×1