New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add isCurrentlyAudible() to WebContents #13614
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if it will take more than 100ms for the oscillator to become audible? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It never should. In theory, it should start immediately, but the Web Audio API is still a working draft, so I've added the 100ms to ensure that we'll never have a flaky test, even if you're running the test on the slowest of all machines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, if you say so =) |
||
}) | ||
</script> | ||
</body> | ||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use our event helpers and Chai's
expect
here: