I'm setting up a test that involves starting a webcam video session.
So far all is working fine and doesn't require any user interaction except for granting access to the webcam.
When the third party library I'm using makes the call: navigator.mediaDevices.getUserMedia({audio: true, video: true})
the browser opens a prompt asking the user to allow access.
What I'm looking for is a way to grant access without user interaction.
I've tried puppeteer's page.on('dialog'...
but that doesn't get called for the webcam access prompt.
Please let me know if you have any ideas?
Google Chrome has a launch option --use-fake-ui-for-media-stream
that allows the user to skip a prompt of getUserMedia.
And you can set it with puppeteer like below.
const puppeteer = require('puppeteer')
;(async () => {
const browser = await puppeteer.launch({
args: [ '--use-fake-ui-for-media-stream' ]
})
const page = await browser.newPage()
await page.goto('http://localhost/start-video-test.html')
const startVideoButton = await page.$('#startVideoButton')
startVideoButton.click()
// video session starts without prompt
return browser.close()
})()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With