From bf0ef83964741dcd64d27a8da651e65beba7e451 Mon Sep 17 00:00:00 2001 From: jordan lavatai Date: Wed, 5 Jul 2017 14:46:21 -0700 Subject: [PATCH] getUserMedia problem in firefox --- client.js | 11 ++++++++--- host.js | 18 ++++++++++++++++++ skel.html | 3 ++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/client.js b/client.js index 2aa4950..f38f3ab 100644 --- a/client.js +++ b/client.js @@ -1,8 +1,6 @@ const body = document.createElement('body') const root = document.createElement('div') document.title = "Strapp.io Client" -body.appendChild(root) -document.body = body const conf = {"iceServers": [{ "urls": "stun:stun.1.google.com:19302" }] } let dataChannel @@ -179,10 +177,17 @@ getPublicKey().then((cpk) => { /* Start data channel */ dataChannel = cpc.createDataChannel("sendChannel"); dataChannel.onmessage = (msg) => { - console.log(msg.data) + /* Get mediaStream from host and add it to the video */ + let video = document.querySelector('') } dataChannel.onopen = () => { dataChannel.send(`Hi from the Client`) + document.write(' ') } }) +document.addEventListener('DOMContentLoaded', () => { + + document.body.innerHTML = `` + +}); diff --git a/host.js b/host.js index 01c56a2..81aabc6 100644 --- a/host.js +++ b/host.js @@ -1,4 +1,6 @@ document.title = "Strapp.io Host" + + const conf = {"iceServers": [{ "urls": "stun:stun.1.google.com:19302" }] } const clients = new Map([]) const iceCandidates = [] @@ -154,6 +156,22 @@ if ("WebSocket" in window) { } } } + document.body.innerHTML = '
Choose options for client
' + + navigator.mediaDevices.getUserMedia({ video : { mediaSource: "screen", // whole screen sharing + // mediaSource: "window", // choose a window to share + // mediaSource: "application", // choose a window to share + width: {max: '1920'}, + height: {max: '1080'}, + frameRate: {max: '10'}} }) + .then(function(mediaStream) { + let video = document.querySelector('video') + video.srcObject = mediaStream + video.onloadedmetadata = function(e) { + video.play() + } + }) + .catch(function(err) { console.log(err); }); // always check for errors at the end. }) } else { diff --git a/skel.html b/skel.html index 55559f4..277b632 100644 --- a/skel.html +++ b/skel.html @@ -7,7 +7,8 @@ - + + -- 2.18.0