Skip to content

Commit fb03280

Browse files
committed
getUserMedia browser support
1 parent fd71cb8 commit fb03280

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

p2p-video-chat-webrtc/index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
navigator.getMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;
2-
navigator.getMedia({ video: true, audio: false }, function (stream) {
1+
// The following lines try to handle getUserMedia in many different browsers
2+
if (navigator.mediaDevices.getUserMedia) {
3+
function getUserMedia (constraints, ready, err) {
4+
navigator.mediaDevices.getUserMedia(constraints).then(ready).catch(err)
5+
}
6+
} else {
7+
var getUserMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia).bind(navigator)
8+
if (!getUserMedia) {
9+
throw new Error('getUserMedia is not supported')
10+
}
11+
}
12+
13+
getUserMedia({ video: true, audio: false }, function (stream) {
314
var Peer = require('simple-peer')
415
var peer = new Peer({
516
initiator: location.hash === '#init',

0 commit comments

Comments
 (0)