I was developing a chrome plugin in which captures desktop screen. I am using the sample plugin example given here... https://developer.chrome.com/extensions/samples#desktop-capture-example But in this example as we click the start button a dialog pop ups which asks the user which screen or window to share but I want to share my current screen what changes do I make in this code
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function gotStream(stream) {
console.log("Received local stream");
var video = document.querySelector("video");
video.src = URL.createObjectURL(stream);
localstream = stream;
stream.onended = function() { console.log("Ended"); };
}
function getUserMediaError() {
console.log("getUserMedia() failed.");
}
function onAccessApproved(id) {
if (!id) {
console.log("Access rejected.");
return;
}
navigator.webkitGetUserMedia({
audio:false,
video: { mandatory: { chromeMediaSource: "desktop",
chromeMediaSourceId: id } }
}, gotStream, getUserMediaError);
}
var pending_request_id = null;
document.querySelector('#start').addEventListener('click', function(e) {
pending_request_id = chrome.desktopCapture.chooseDesktopMedia(
["screen"], onAccessApproved);
});
document.querySelector('#cancel').addEventListener('click', function(e) {
if (pending_request_id != null) {
chrome.desktopCapture.cancelChooseDesktopMedia(pending_request_id);
}
});
what should be the value of the chromeMediaSourceId so that the default selection is the current screen;
basically i want to avoid this screen ..
Plz help... Regards
To enable the Screenshot feature in Chrome, go to chrome://flags and search for Screenshots. In the dropdown for “Desktop Screenshots”, select Enabled. You'll see a prompt to restart the browser, click on that.
Android Intelligence Advice Here's a little-known secret: Chrome actually has a supremely useful built-in command for capturing screenshots — no extensions required. It's flexible, effective, and easy as can be to use.
You can't do this. The manifest permission allows you to provide this feature but the user still has to select the screen and hit share.
Like others said, this is a security feature to prevent your extension from triggering this without informing the user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With