【发布时间】: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