0

我尝试了下面的代码

   localPeerConnection.addTrack(await localStream)
   remotePeerConnection.ontrack = () => {
      const remoteStreamVideoElement = document.querySelector("#remoteStreamVideoElement")
      remoteStreamVideoElement.srcObject = localStream
      remoteStreamVideoElement.onloadedmetadata = () => remoteStreamVideoElement.play()
   }

但它返回了这个错误

TypeError: Argument 1 of RTCPeerConnection.addTrack does not implement interface MediaStreamTrack.

4

1 回答 1

0

您需要添加轨道而不是流。API 参考和示例可以在这里看到。

localStream.getTracks().forEach(track => localPeerConnection.addTrack(track));
于 2020-11-21T12:21:07.577 回答