【问题标题】:video tag not displaying webrtc stream video with Angular 5视频标签不显示 Angular 5 的 webrtc 流视频
【发布时间】:2018-05-07 11:48:10
【问题描述】:

xyz.html

<video id="localVideo" #localVideo autoplay="autoplay"></video> <video id="remoteVideo" #remoteVideo autoplay="autoplay"></video> <button (click)="startVideoCall()">Start video call </button>

xyz.ts

    @ViewChild ('localVideo') public localVideo:ElementRef;
    @ViewChild ('remoteVideo') public remoteVideo:ElementRef;

    //on getUserMedia
           this.localVideo.nativeElement.src = window.URL.createObjectURL(stream);
    this.localVideo.nativeElement.play();

    // on receiving the remote stream
    this.remoteVideo.nativeElement.src = window.URL.createObjectURL(event.stream);
    this.remoteVideo.nativeElement.play();

我正在将 WebRTC 用于视频通话应用程序。问题是我能够看到我的本地视频。但同样不适用于远程视频。当我检查 remoteVideo 视频标签上的元素时,我可以看到 url。我收到远程流时的 enitre 标签如下: &lt;video _ngcontent-c7="" autoplay="autoplay" id="remoteVideo" src="blob:http://localhost:4200/832b72ca-4184-4215-9ab6-276242bf0291"&gt;&lt;/video&gt; 但视频不可见。 任何帮助,将不胜感激。 谢谢。

【问题讨论】:

    标签: html angular html5-video webrtc


    【解决方案1】:

    也许这样,支持这两种类型:

    try {
    
        this.remoteVideo.nativeElement.srcObject = event.stream;
    
    } catch(error) {
    
        this.remoteVideo.nativeElement.src = URL.createObjectURL(event.stream);
    };
    
    this.remoteVideo.nativeElement.play();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-01
      • 1970-01-01
      • 2014-07-11
      • 1970-01-01
      • 2014-07-02
      • 1970-01-01
      相关资源
      最近更新 更多