Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force this to work on chrome with/without https #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions js/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if (navigator.mozGetUserMedia) {
MediaStream.prototype.getAudioTracks = function () {
return []
}
} else if (navigator.webkitGetUserMedia) {
} else {//} if (navigator.webkitGetUserMedia || navigator.webkitGetUserMedia) {
console.log('This appears to be Chrome')

webrtcDetectedBrowser = 'chrome'
Expand All @@ -53,7 +53,9 @@ if (navigator.mozGetUserMedia) {

// Get UserMedia (only difference is the prefix).
// Code from Adam Barth.
getUserMedia = navigator.webkitGetUserMedia.bind(navigator)
//getUserMedia = navigator.webkitGetUserMedia.bind(navigator)
if(navigator.mediaDevices)//Non HTTPS booo...
getUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices)

// Attach a media stream to an element.
attachMediaStream = function (element, stream) {
Expand Down Expand Up @@ -84,6 +86,6 @@ if (navigator.mozGetUserMedia) {
return this.remoteStreams
}
}
} else {
console.log('Browser does not appear to be WebRTC-capable')
}
} //else {
//console.log('Browser does not appear to be WebRTC-capable')
//}
26 changes: 18 additions & 8 deletions js/serverless-webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ $('#waitForConnection').modal('hide')
$('#createOrJoin').modal('show')

$('#createBtn').click(function () {
$('#createOrJoin').modal('hide')
$('#showLocalOffer').modal('show')
createLocalOffer()
})
Expand All @@ -42,14 +43,15 @@ $('#joinBtn').click(function () {
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia
navigator.getUserMedia({video: true, audio: true}, function (stream) {
navigator.getUserMedia && navigator.getUserMedia({video: true, audio: true}, function (stream) {
var video = document.getElementById('localVideo')
video.src = window.URL.createObjectURL(stream)
video.play()
pc2.addStream(stream)
}, function (error) {
console.log('Error adding stream to pc2: ' + error)
})
$('#createOrJoin').modal('hide')
$('#getRemoteOffer').modal('show')
})

Expand Down Expand Up @@ -156,25 +158,33 @@ function createLocalOffer () {
console.log('video1')
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mediaDevices.getUserMedia ||
(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia) ||
navigator.msGetUserMedia
navigator.getUserMedia({video: true, audio: true}, function (stream) {
navigator.getUserMedia && navigator.getUserMedia({video: true, audio: true}, function (stream) {
var video = document.getElementById('localVideo')
video.src = window.URL.createObjectURL(stream)
video.play()
pc1.addStream(stream)
console.log(stream)
console.log('adding stream to pc1')
setupDC1()
pc1.createOffer(function (desc) {
// pc1.createOffer(function (desc) {
// pc1.setLocalDescription(desc, function () {}, function () {})
// console.log('created local offer', desc)
// },
// function () { console.warn("Couldn't create offer") },
// sdpConstraints)
}, function (error) {
console.log('Error adding stream to pc1: ' + error)
})


setupDC1()
pc1.createOffer(function (desc) {
pc1.setLocalDescription(desc, function () {}, function () {})
console.log('created local offer', desc)
},
function () { console.warn("Couldn't create offer") },
sdpConstraints)
}, function (error) {
console.log('Error adding stream to pc1: ' + error)
})
}

pc1.onicecandidate = function (e) {
Expand Down
2 changes: 1 addition & 1 deletion serverless-webrtc.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<input type="file" id="fileBtn">
</div>

<div class="modal" id="showLocalOffer" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" hidden>
<div class="modal" id="showLocalOffer" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" hidden no-enforce-focus="true">
<div class="modal-header">
<h3 id="myModalLabel">Send your local offer to someone else</h3>
</div>
Expand Down