Use addTrack instead of addStream in examples

Logs: TypeError: pc.addStream is not a function.
Fixed js error when using safari due to deprecated
RTCPeerConnection.addStream() method.

Updated js fiddle examples to use the addTrack()
method instead.
This commit is contained in:
Jamie Good
2020-10-14 17:22:17 +01:00
committed by Sean DuBois
parent fdbf5b5c90
commit 63112a4ed4
6 changed files with 10 additions and 5 deletions

View File

@@ -13,7 +13,10 @@ var log = msg => {
navigator.mediaDevices.getUserMedia({ video: true, audio: true })
.then(stream => {
pc.addStream(document.getElementById('video1').srcObject = stream)
document.getElementById('video1').srcObject = stream
stream.getTracks().forEach(track => pc.addTrack(track, stream));
pc.createOffer().then(d => pc.setLocalDescription(d)).catch(log)
}).catch(log)