double mute after double tap solved
This commit is contained in:
parent
43a60ed1b1
commit
362f754681
BIN
assets/icon.ico
BIN
assets/icon.ico
Binary file not shown.
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 5.4 KiB |
74
main.js
74
main.js
@ -61,48 +61,68 @@ const ioHook = require('iohook')
|
|||||||
const win = require('win-audio')
|
const win = require('win-audio')
|
||||||
const microphone = win.mic
|
const microphone = win.mic
|
||||||
|
|
||||||
let talkOpen = false
|
|
||||||
|
|
||||||
function toggleMicOpen() {
|
let isTalking = false
|
||||||
if (talkOpen === false) {
|
|
||||||
setTimeout(function (){
|
// Resolves the promise after 2 seconds
|
||||||
talkOpen = false
|
function muteDelay() {
|
||||||
console.log("Muted")
|
return new Promise((resolve) => {
|
||||||
mainWindow.webContents.send('ping', 'mic-closed')
|
setTimeout(function(){
|
||||||
mainWindow.setTitle("MUTED")
|
return resolve(true)
|
||||||
microphone.mute();
|
}, 1300);
|
||||||
}, 2000);
|
})
|
||||||
}else {
|
}
|
||||||
talkOpen = true
|
|
||||||
|
// Mutes the Mic
|
||||||
|
function muteMic() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
if (isTalking === false) {
|
||||||
|
muteDelay().then(val => {
|
||||||
|
if (isTalking === false) {
|
||||||
|
microphone.mute(); // Mute mic
|
||||||
|
console.log("Muted")
|
||||||
|
mainWindow.webContents.send('ping', 'mic-closed')
|
||||||
|
mainWindow.setTitle("MUTED")
|
||||||
|
return resolve(true)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function unmuteMic() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
console.log("Talking")
|
console.log("Talking")
|
||||||
|
isTalking = true
|
||||||
mainWindow.webContents.send('ping', 'mic-open')
|
mainWindow.webContents.send('ping', 'mic-open')
|
||||||
mainWindow.setTitle("MIC OPEN")
|
mainWindow.setTitle("MIC OPEN")
|
||||||
microphone.unmute();
|
microphone.unmute(); // Unmute mic
|
||||||
}
|
return resolve(true)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
app.on('ready', event => {
|
app.on('ready', event => {
|
||||||
talkOpen = false
|
|
||||||
toggleMicOpen()
|
|
||||||
ioHook.start();
|
ioHook.start();
|
||||||
ioHook.start(true);
|
|
||||||
console.log("Init done")
|
console.log("Init Finished")
|
||||||
|
|
||||||
|
console.log("Muted")
|
||||||
|
microphone.mute();
|
||||||
|
mainWindow.webContents.send('ping', 'mic-closed')
|
||||||
|
mainWindow.setTitle("MUTED")
|
||||||
})
|
})
|
||||||
|
|
||||||
ioHook.on('mousedown', event => {
|
ioHook.on('mousedown', event => {
|
||||||
if (event.button == '4') {
|
if (event.button == '4') {
|
||||||
if (talkOpen === false) {
|
unmuteMic()
|
||||||
talkOpen = true
|
|
||||||
toggleMicOpen()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ioHook.on('mouseup', event => {
|
ioHook.on('mouseup', event => {
|
||||||
if (event.button == '4') {
|
if (event.button == '4') {
|
||||||
if (talkOpen === true) {
|
isTalking = false
|
||||||
talkOpen = false
|
muteMic()
|
||||||
toggleMicOpen()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user