feat: Add isCurrentlyAudible() to WebContents (#13614)
* 🔧 Add isCurrentlyAudible() to WebContents * ❤️ Implement feedback, use await to wait for event * 👷 Add missing imports
This commit is contained in:
parent
e90c4abc0d
commit
deedf6c3f4
7 changed files with 57 additions and 0 deletions
21
spec/fixtures/api/is-currently-audible.html
vendored
Normal file
21
spec/fixtures/api/is-currently-audible.html
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
<html>
|
||||
<body>
|
||||
<div id="video"></div>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
const {ipcRenderer} = window.top != null ? window.top.require('electron') : require('electron')
|
||||
ipcRenderer.on('play', (event) => {
|
||||
const context = new window.AudioContext();
|
||||
const oscillator = context.createOscillator();
|
||||
|
||||
// A beep
|
||||
oscillator.type = 'sine';
|
||||
oscillator.frequency.value = 440
|
||||
oscillator.connect(context.destination)
|
||||
oscillator.start()
|
||||
|
||||
// It'll take a few ms before the beep shows up
|
||||
setTimeout(() => event.sender.send('playing'), 100)
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue