moved audio

This commit is contained in:
khlam 2019-10-14 11:31:48 -07:00
parent 2bbbd2528a
commit bf828300f0
3 changed files with 8 additions and 14 deletions

View File

@ -9,9 +9,5 @@
<webview src="https://discordapp.com/login"></webview> <webview src="https://discordapp.com/login"></webview>
<script src="./renderer.js"></script> <script src="./renderer.js"></script>
<audio id="unmute" src="./assets/unmute.mp3" autoplay="false" ></audio>
<audio id="mute" src="./assets/mute.mp3" autoplay="false" ></audio>
</body> </body>
</html> </html>

View File

@ -64,6 +64,7 @@ const microphone = win.mic
let isTalking = false let isTalking = false
// Resolves the promise after 2 seconds // Resolves the promise after 2 seconds
function muteDelay() { function muteDelay() {
return new Promise((resolve) => { return new Promise((resolve) => {
@ -79,7 +80,7 @@ function muteMic() {
if (isTalking === false) { if (isTalking === false) {
muteDelay().then(val => { muteDelay().then(val => {
if (isTalking === false) { if (isTalking === false) {
microphone.mute(); // Mute mic microphone.mute() // Mute mic
console.log("Muted") console.log("Muted")
mainWindow.webContents.send('ping', 'mic-closed') mainWindow.webContents.send('ping', 'mic-closed')
mainWindow.setTitle("MUTED") mainWindow.setTitle("MUTED")
@ -123,6 +124,4 @@ ioHook.on('mouseup', event => {
isTalking = false isTalking = false
muteMic() muteMic()
} }
}) })

View File

@ -1,14 +1,13 @@
const unMuteSound = new Audio('./assets/unmute.mp3')
const muteSound = new Audio('./assets/mute.mp3')
require('electron').ipcRenderer.on('ping', (event, message) => { require('electron').ipcRenderer.on('ping', (event, message) => {
if (message === 'mic-open'){ if (message === 'mic-open'){
console.log("mic is open") console.log("mic is open")
let unmute = document.getElementById("unmute"); unMuteSound.play()
unmute.volume=0.3
unmute.play();
} }
if (message === 'mic-closed'){ if (message === 'mic-closed'){
console.log("mic is closed") console.log("mic is closed")
let mute = document.getElementById("mute"); muteSound.play()
mute.volume=0.3
mute.play();
} }
}) })