mirror of
https://github.com/pion/webrtc.git
synced 2025-10-30 10:16:36 +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:
@@ -207,6 +207,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu
|
||||
* [Rahul Nakre](https://github.com/rahulnakre)
|
||||
* [OrlandoCo](https://github.com/OrlandoCo)
|
||||
* [Assad Obaid](https://github.com/assadobaid)
|
||||
* [Jamie Good](https://github.com/jamiegood) - *Bug fix in jsfiddle example*
|
||||
|
||||
### License
|
||||
MIT License - see [LICENSE](LICENSE) for full text
|
||||
|
||||
@@ -9,7 +9,7 @@ go get github.com/pion/webrtc/v3/examples/reflect
|
||||
```
|
||||
|
||||
### 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
|
||||
In the jsfiddle the top textarea is your browser, copy that and:
|
||||
|
||||
@@ -9,7 +9,7 @@ go get github.com/pion/webrtc/v3/examples/rtp-forwarder
|
||||
```
|
||||
|
||||
### 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
|
||||
In the jsfiddle the top textarea is your browser, copy that and:
|
||||
|
||||
@@ -13,7 +13,8 @@ var log = msg => {
|
||||
|
||||
navigator.mediaDevices.getUserMedia({ video: true, audio: true })
|
||||
.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)
|
||||
}).catch(log)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ go get github.com/pion/webrtc/v3/examples/save-to-disk
|
||||
```
|
||||
|
||||
### 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
|
||||
In the jsfiddle the top textarea is your browser, copy that and:
|
||||
|
||||
@@ -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