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

@@ -207,6 +207,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu
* [Rahul Nakre](https://github.com/rahulnakre) * [Rahul Nakre](https://github.com/rahulnakre)
* [OrlandoCo](https://github.com/OrlandoCo) * [OrlandoCo](https://github.com/OrlandoCo)
* [Assad Obaid](https://github.com/assadobaid) * [Assad Obaid](https://github.com/assadobaid)
* [Jamie Good](https://github.com/jamiegood) - *Bug fix in jsfiddle example*
### License ### License
MIT License - see [LICENSE](LICENSE) for full text MIT License - see [LICENSE](LICENSE) for full text

View File

@@ -9,7 +9,7 @@ go get github.com/pion/webrtc/v3/examples/reflect
``` ```
### Open reflect example page ### Open reflect example page
[jsfiddle.net](https://jsfiddle.net/j3yhron4/) you should see two text-areas and a 'Start Session' button. [jsfiddle.net](https://jsfiddle.net/9jgukzt1/) you should see two text-areas and a 'Start Session' button.
### Run reflect, with your browsers SessionDescription as stdin ### Run reflect, with your browsers SessionDescription as stdin
In the jsfiddle the top textarea is your browser, copy that and: In the jsfiddle the top textarea is your browser, copy that and:

View File

@@ -9,7 +9,7 @@ go get github.com/pion/webrtc/v3/examples/rtp-forwarder
``` ```
### Open rtp-forwarder example page ### Open rtp-forwarder example page
[jsfiddle.net](https://jsfiddle.net/sq69370h/) you should see your Webcam, two text-areas and a 'Start Session' button [jsfiddle.net](https://jsfiddle.net/os73epj4/) you should see your Webcam, two text-areas and a 'Start Session' button
### Run rtp-forwarder, with your browsers SessionDescription as stdin ### Run rtp-forwarder, with your browsers SessionDescription as stdin
In the jsfiddle the top textarea is your browser, copy that and: In the jsfiddle the top textarea is your browser, copy that and:

View File

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

View File

@@ -11,7 +11,7 @@ go get github.com/pion/webrtc/v3/examples/save-to-disk
``` ```
### Open save-to-disk example page ### Open save-to-disk example page
[jsfiddle.net](https://jsfiddle.net/b3d72av1/) you should see your Webcam, two text-areas and a 'Start Session' button [jsfiddle.net](https://jsfiddle.net/vfmcg8rk/1/) you should see your Webcam, two text-areas and a 'Start Session' button
### Run save-to-disk, with your browsers SessionDescription as stdin ### Run save-to-disk, with your browsers SessionDescription as stdin
In the jsfiddle the top textarea is your browser, copy that and: In the jsfiddle the top textarea is your browser, copy that and:

View File

@@ -13,7 +13,10 @@ var log = msg => {
navigator.mediaDevices.getUserMedia({ video: true, audio: true }) navigator.mediaDevices.getUserMedia({ video: true, audio: true })
.then(stream => { .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) pc.createOffer().then(d => pc.setLocalDescription(d)).catch(log)
}).catch(log) }).catch(log)