Skip to content

Commit b5d27eb

Browse files
jamiegoodSean-Der
authored andcommitted
Found a JS Error when running the example JS fiddle code in safari.
Logs: TypeError: pc.addStream is not a function. (In 'pc.addStream(displayVideo(stream))', 'pc.addStream' is undefined) Fixed js error when using safari due to deprecated RTCPeerConnection.addStream() method. Updated js fiddle example to use the addTrack() method instead. https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addStream
1 parent ea3ce4d commit b5d27eb

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu
6868
* [Alexey Kravtsov](https://github.com/alexey-kravtsov) - *GStreamer encoder tune*
6969
* [Tarrence van As](https://github.com/tarrencev) - *Webm saver fix*
7070
* [Cameron Elliott](https://github.com/cameronelliott) - *Small race bug fix*
71+
* [Jamie Good](https://github.com/jamiegood) - *Bug fix in jsfiddle example*
7172

7273
### License
7374
MIT License - see [LICENSE](LICENSE) for full text

gstreamer-receive/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ go get github.com/pion/example-webrtc-applications/gstreamer-receive
1717
```
1818

1919
### Open gstreamer-receive example page
20-
[jsfiddle.net](https://jsfiddle.net/8t2g5Lar/) you should see your Webcam, two text-areas and a 'Start Session' button
20+
[jsfiddle.net](https://jsfiddle.net/cqavdpj8/1/) you should see your Webcam, two text-areas and a 'Start Session' button
2121

2222
### Run gstreamer-receive with your browsers SessionDescription as stdin
2323
In the jsfiddle the top textarea is your browser, copy that and:

gstreamer-receive/jsfiddle/demo.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ let displayVideo = video => {
2424

2525
navigator.mediaDevices.getUserMedia({ video: true, audio: true })
2626
.then(stream => {
27-
pc.addStream(displayVideo(stream))
27+
28+
stream.getTracks().forEach(function(track) {
29+
pc.addTrack(track, stream);
30+
});
31+
32+
displayVideo(stream)
2833
pc.createOffer().then(d => pc.setLocalDescription(d)).catch(log)
2934
}).catch(log)
3035

@@ -51,7 +56,11 @@ window.startSession = () => {
5156
window.addDisplayCapture = () => {
5257
navigator.mediaDevices.getDisplayMedia().then(stream => {
5358
document.getElementById('displayCapture').disabled = true
54-
pc.addStream(displayVideo(stream))
59+
60+
stream.getTracks().forEach(function(track) {
61+
pc.addTrack(track, displayVideo(stream));
62+
});
63+
5564
pc.createOffer().then(d => pc.setLocalDescription(d)).catch(log)
5665
})
5766
}

twitch/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ go get github.com/pion/example-webrtc-applications/twitch
1717
```
1818

1919
### Open twitch example page
20-
[jsfiddle.net](https://jsfiddle.net/8t2g5Lar/) you should see your Webcam, two text-areas and a 'Start Session' button
20+
[jsfiddle.net](https://jsfiddle.net/cqavdpj8/1/) you should see your Webcam, two text-areas and a 'Start Session' button
2121

2222
### Run twitch with your browsers SessionDescription as stdin and stream-key as an argument
2323
In the jsfiddle the top textarea is your browser, copy that and:

0 commit comments

Comments
 (0)