aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.html9
1 files changed, 5 insertions, 4 deletions
diff --git a/index.html b/index.html
index ab9b120..fc641bf 100644
--- a/index.html
+++ b/index.html
@@ -30,7 +30,7 @@
pc.ontrack = function (event) {
if (event.track.kind === 'audio') {
- return
+ //return
}
var el = document.getElementById('video1')
el.srcObject = event.streams[0]
@@ -41,12 +41,13 @@
conn.onopen = () => {
navigator.mediaDevices.getUserMedia({video: true, audio: true}).then(g => {
for (const track of g.getTracks()) {
- pc.addTrack(track);
+ pc.addTrack(track,g);
}
pc.createOffer({offerToReceiveVideo: true, offerToReceiveAudio: true}).then(offer => {
- pc.setLocalDescription(offer)
- conn.send(JSON.stringify({event: 'offer', data: JSON.stringify(offer)}))
+ return pc.setLocalDescription(offer);
+ }).then(() => {
+ conn.send(JSON.stringify({event: 'offer', data: JSON.stringify(pc.localDescription)}))
})
}).catch(e => { console.log(`failed getUserMedia: ${e}`) });
}