mirror of
https://github.com/pion/webrtc.git
synced 2025-10-05 07:06:51 +08:00
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:
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user