Skip to content
This repository has been archived by the owner on Apr 4, 2019. It is now read-only.

Commit

Permalink
latest commit
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Nov 28, 2016
1 parent 2bf6664 commit a1168db
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# getScreenId | Capture Screen on Any Domain!

* Live Demo: https://www.webrtc-experiment.com/getScreenId/
* YouTube video: https://www.youtube.com/watch?v=UHrsfe9RYAQ

1. Install this: https://chrome.google.com/webstore/detail/screen-capturing/ajhifddimkapgcifgcodmmfdlknahffk
2. Now use below codes on any HTTPs domain.
Expand Down
30 changes: 29 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,25 @@ <h1>

<div class="github-stargazers"></div>

<blockquote>
YouTube video: <a href="https://www.youtube.com/watch?v=UHrsfe9RYAQ" target="_blank">https://www.youtube.com/watch?v=UHrsfe9RYAQ</a>
</blockquote>

<section class="experiment" style="text-align:center;">
<br><button id="capture-screen">Capture Your Own Screen</button><hr>
<video controls autoplay style="width: 100%;background-repeat: no-repeat;background-size: 100%;background-image: url(https://lh5.googleusercontent.com/6U-gmL_hG9bbquDZdW_ajiA-1bgkfSlHOkzR24aigkyPQzXWXNoRNfyLjXS3rqV92iwq395JSQ=s640-h400-e365-rw);"></video>
</section>

<script>
// via: https://bugs.chromium.org/p/chromium/issues/detail?id=487935#c17
// you can capture screen on Android Chrome >= 55 with flag: "Experimental ScreenCapture android"
window.IsAndroidChrome = false;
try {
if (navigator.userAgent.toLowerCase().indexOf("android") > -1 && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor)) {
window.IsAndroidChrome = true;
}
} catch (e) {}

document.getElementById('capture-screen').onclick = function() {
document.getElementById('capture-screen').disabled = true;

Expand All @@ -150,6 +163,21 @@ <h1>

document.getElementById('capture-screen').disabled = false;

if (IsAndroidChrome) {
screen_constraints = {
mandatory: {
chromeMediaSource: 'screen'
},
optional: []
};

screen_constraints = {
video: screen_constraints
};

error = null;
}

if(error == 'not-installed') {
alert('Please install Chrome extension. See the link below.');
return;
Expand All @@ -171,7 +199,7 @@ <h1>
navigator.getUserMedia = navigator.mozGetUserMedia || navigator.webkitGetUserMedia;
navigator.getUserMedia(screen_constraints, function(stream) {
// share this "MediaStream" object using RTCPeerConnection API

document.querySelector('video').src = URL.createObjectURL(stream);

stream.oninactive = stream.onended = function() {
Expand Down

0 comments on commit a1168db

Please sign in to comment.