【问题标题】:Unexpected token 'o', "[object Blob]" is not valid JSON意外令牌 \'o\'、\"[object Blob]\" 不是有效的 JSON
【发布时间】:2022-10-15 16:34:36
【问题描述】:

所以我正在尝试我在 youtube 上找到的视频聊天代码,但是当我尝试建立我的电话时,我最终遇到了这个错误。现在已经有几天了,我不知道问题出在哪里

这是代码


  private localStream: MediaStream;

  inCall = false;
  localVideoActive = false;


  constructor(private dataService: DataService) { }

  async call(): Promise<void> {
    this.createPeerConnection();


    // Add the tracks from the local stream to the RTCPeerConnection
    this.localStream.getTracks().forEach(
      track => this.peerConnection.addTrack(track, this.localStream)
    );

    try {
      const offer: RTCSessionDescriptionInit = await this.peerConnection.createOffer(offerOptions);
      // Establish the offer as the local peer's current description.
      await this.peerConnection.setLocalDescription(offer);

      this.inCall = true;

      this.dataService.sendMessage({type: 'offer', data: offer});
    } catch (err:any) {
      this.handleGetUserMediaError(err);
    }```

【问题讨论】:

    标签: angular typescript webrtc


    【解决方案1】:

    如下所述更新您的 websocket 发送消息

     ws.on("message", function message(data, isBinary) {
        const message = isBinary ? data : data.toString();
        // Continue as before.
        console.log(message + "
    
    ");
        wss.broadcast(ws, message);
      });

    【讨论】:

      猜你喜欢
      • 2012-09-21
      • 2019-12-10
      • 2016-02-18
      • 2015-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多