I am using Chrome desktopCapture API to create a screen recording Chrome App.
Currently, I am doing this:
app.js:
document.querySelector('#startRecording').addEventListener('click', recordClick);
function recordClick(event) {
console.log("Start Button clicked");
pending_request_id = chrome.desktopCapture.chooseDesktopMedia(["screen"], accessToRecord);
}
function accessToRecord(id, options){
if (!id) {
console.log('Access rejected.');
return;
}
let audioConstraint = {
mandatory: {
chromeMediaSource: 'desktop',
chromeMediaSourceId: id
}
};
console.log(options.canRequestAudioTrack);
if (!options.canRequestAudioTrack)
audioConstraint = false;
//console.log("id is: "+id);
navigator.webkitGetUserMedia({
audio : audioConstraint,
video : {
mandatory: {
chromeMediaSource: 'desktop',
chromeMediaSourceId: id,
maxWidth:screen.width,
maxHeight:screen.height
}
}
}, startStream, failedStream);
}
background.js:
chrome.app.runtime.onLaunched.addListener(function() {
console.log("Launch Link Clicked");
chrome.app.window.create('index.html', {
bounds: {
width: 800,
height: 600
}
});
});
manifest.json:
{
"manifest_version" : 2,
"name" : "My Screen Recorder",
"description" : "Allows screen recording",
"version" : "1",
"app" : {
"background" : {
"scripts" : ["background.js"]
}
},
"permissions" : ["desktopCapture"]
}
Behavior this creates on UI:
- I click on my Chrome App and it shows me a "Start Recording" button(id=startRecording used in above code). Start Recording button - custom screen
- Once I clock on this button it shows me this Google screen to select what I want to record: Google's Choose media prompt
- Then I start using this screen.
What I want to achieve: A way to bypass this Google generated screen to choose the Media to be recorded. I want to pass the media type in my code and on clicking the first "Start Recording" button, I want it to start recording the type I passed in code and not show me the Choose media prompt.
Is it possible to do that?