diff --git a/public/index.html b/public/index.html index cf1fa21..07bd20e 100644 --- a/public/index.html +++ b/public/index.html @@ -68,6 +68,10 @@ +
+
+ Share screen +
diff --git a/public/main.js b/public/main.js index 0d3460e..0492ccd 100644 --- a/public/main.js +++ b/public/main.js @@ -218,7 +218,68 @@ var app = new Vue({ element.setSelectionRange(0, 99999); /*For mobile devices*/ document.execCommand("copy"); alert("Copied the text: " + element.value); - } + }, + getScreen: function(error, sourceId, screen_constraints) { + if (IsAndroidChrome) { + screen_constraints = { + mandatory: { + chromeMediaSource: 'screen' + }, + optional: [] + }; + + screen_constraints = { + video: screen_constraints + }; + + error = null; + } + + console.log('screen_constraints', JSON.stringify(screen_constraints, null, '\t')); + navigator.mediaDevices.getUserMedia(screen_constraints).then(function(stream) { + addStreamStopListener(stream, function() { + if (self.onuserleft) self.onuserleft('self'); + }); + + self.stream = stream; + + var video = document.createElement('video'); + video.id = 'self'; + video.muted = true; + video.volume = 0; + + try { + video.setAttributeNode(document.createAttribute('autoplay')); + video.setAttributeNode(document.createAttribute('playsinline')); + video.setAttributeNode(document.createAttribute('controls')); + } catch (e) { + video.setAttribute('autoplay', true); + video.setAttribute('playsinline', true); + video.setAttribute('controls', true); + } + + video.srcObject = stream; + + self.onaddstream({ + video: video, + stream: stream, + userid: 'self', + type: 'local' + }); + + callback(stream); + }).catch(function(error) { + if (adapter.browserDetails.browser === 'chrome' && location.protocol === 'http:') { + alert('HTTPs is required.'); + } else if (adapter.browserDetails.browser === 'chrome') { + alert('Screen capturing is either denied or not supported. Please install chrome extension for screen capturing or run chrome with command-line flag: --enable-usermedia-screen-capturing'); + } else if (adapter.browserDetails.browser === 'firefox') { + alert(Firefox_Screen_Capturing_Warning); + } + + console.error(error); + }); + } }, mounted() { console.log('VUE is alive!');