Click here to Skip to main content
15,609,601 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How should i pass a localStream object as an argument to an
rtcpeerconnection addtrack method

I tried the code below but it returned this error

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

What I have tried:

localPeerConnection.addTrack(await localStream)
            remotePeerConnection.ontrack = () => {
                const remoteStreamVideoElement = document.querySelector("#remoteStreamVideoElement")
                remoteStreamVideoElement.srcObject = localStream
                remoteStreamVideoElement.onloadedmetadata = () =>
Updated 23-Nov-20 20:19pm

1 solution

The error is telling you that whatever your localStream promise returns, it can't be passed to the addTrack method.

We can't tell you how to fix that, since you haven't shown how the localStream variable is initialized.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900