webview test
This commit is contained in:
parent
bf828300f0
commit
08bbc24504
@ -6,7 +6,7 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<webview src="https://discordapp.com/login"></webview>
|
||||
<webview id="discord" src="https://discordapp.com/login"></webview>
|
||||
|
||||
<script src="./renderer.js"></script>
|
||||
</body>
|
||||
|
7
main.js
7
main.js
@ -18,7 +18,7 @@ function createWindow () {
|
||||
webviewTag: true
|
||||
}
|
||||
})
|
||||
mainWindow.setMenu(null)
|
||||
//mainWindow.setMenu(null)
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
@ -61,10 +61,8 @@ const ioHook = require('iohook')
|
||||
const win = require('win-audio')
|
||||
const microphone = win.mic
|
||||
|
||||
|
||||
let isTalking = false
|
||||
|
||||
|
||||
// Resolves the promise after 2 seconds
|
||||
function muteDelay() {
|
||||
return new Promise((resolve) => {
|
||||
@ -74,7 +72,7 @@ function muteDelay() {
|
||||
})
|
||||
}
|
||||
|
||||
// Mutes the Mic
|
||||
// Globally mutes the Mic
|
||||
function muteMic() {
|
||||
return new Promise((resolve) => {
|
||||
if (isTalking === false) {
|
||||
@ -91,6 +89,7 @@ function muteMic() {
|
||||
})
|
||||
}
|
||||
|
||||
// Globally unmutes the Mic
|
||||
function unmuteMic() {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log("Talking")
|
||||
|
15
renderer.js
15
renderer.js
@ -1,5 +1,18 @@
|
||||
const unMuteSound = new Audio('./assets/unmute.mp3')
|
||||
const muteSound = new Audio('./assets/mute.mp3')
|
||||
const ipc = require('electron').ipcRenderer;
|
||||
|
||||
onload = () => {
|
||||
const webview = document.querySelector('webview')
|
||||
webview.openDevTools()
|
||||
webview.addEventListener('console-message', (e) => {
|
||||
console.log('D: ', e.message)
|
||||
|
||||
if (e.message === "Close RTCPeerConnection") {
|
||||
console.log("Disconnected from server")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
require('electron').ipcRenderer.on('ping', (event, message) => {
|
||||
if (message === 'mic-open'){
|
||||
@ -11,3 +24,5 @@ require('electron').ipcRenderer.on('ping', (event, message) => {
|
||||
muteSound.play()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user