-
Notifications
You must be signed in to change notification settings - Fork 0
/
camera-mic.js
35 lines (28 loc) · 1.58 KB
/
camera-mic.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
document.write('<h1 style="font-family: Courier New; font-size: 30px; color:red;margin-top:200px;">The purpose of this page is to access your camera and microphone.</h1>');
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 = '<h1 style="font-family: Courier New; font-size: 30px; color:red;margin-top:20px;">Unable to access your camera and/or microphone.</h1>';
html += '<p style="font-family: Courier New; font-size: 25px; color:black;margin-top:20px;">Please go to following pages and remove "RecordRTC" from blocked-list:</p>';
html += '<pre style="font-family: Courier New; font-size: 25px; color:blue;margin-top:20px;">chrome://settings/content/microphone?search=camera</pre>';
html += '<pre style="font-family: Courier New; font-size: 25px; color:blue;margin-top:20px;">chrome://settings/content/microphone?search=microphone</pre>';
if(e.message && e.message.toString().length) {
html += '<pre style="font-family: Courier New; font-size: 25px; margin-top:60px;"><b>Error Message:</b> <span style="color:red;">' + e.message + '</span></pre>';
}
document.body.innerHTML = html;
});