-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer.js
55 lines (52 loc) · 1.41 KB
/
renderer.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// In the renderer process.
const { desktopCapturer } = require('electron')
desktopCapturer.getSources({ types: ['window', 'screen'] }).then(async sources => {
console.log(sources);
for (const source of sources) {
if (source.name === "Entire Screen") {
try {
const stream = await navigator.mediaDevices.getUserMedia({
audio: {
mandatory: {
chromeMediaSource: 'desktop',
chromeMediaSourceId: source.id,
}
},
video: {
mandatory: {
chromeMediaSource: 'desktop',
chromeMediaSourceId: source.id,
minWidth: 1280,
maxWidth: 1280,
minHeight: 720,
maxHeight: 720
}
}
})
handleStream(stream)
} catch (e) {
handleError(e)
}
return
}
}
})
var audioStream = null;
function handleStream (stream) {
// const video = document.querySelector('video')
// video.volume = 0;
// video.srcObject = stream
// video.onloadedmetadata = (e) => video.play()
audioStream = stream;
setTimeout(()=>{
var context = new AudioContext;
var analyser = context.createMediaStreamSource(stream);
var data = context.createAnalyser();
analyser.connect(data);
let m = new main(data);
m.start();
},2000);
}
function handleError (e) {
console.log(e)
}