document.write('
The purpose of this page is to access your camera and microphone.
');
var port = chrome.runtime.connect();
navigator.mediaDevices.getUserMedia({
audio: true,
video: true
}).then(function(stream) {
var tracksLength = stream.getTracks().length;
stream.getTracks().forEach(function(track) {
track.stop();
});
if(tracksLength <= 1) {
throw new Error('Expected two tracks but received: ' + tracksLength);
}
port.postMessage({
messageFromContentScript1234: true,
startRecording: true
});
window.close();
}).catch(function(e) {
var html = 'Unable to access your camera and/or microphone.
';
html += 'Please go to following pages and remove "RecordRTC" from blocked-list:
';
html += 'chrome://settings/content/microphone?search=camera
';
html += 'chrome://settings/content/microphone?search=microphone
';
if(e.message && e.message.toString().length) {
html += 'Error Message: ' + e.message + '
';
}
document.body.innerHTML = html;
});