Closed tomoyamachi closed 3 years ago
I see the arg reading in the Chrome args output as the same path you specified: --use-file-for-fake-audio-capture=cypress/fixtures/sample.wav
Can you detail what the actual issue is? Is the audio file eventually not playing within the web application? What is the error point?
I'm facing the same issue with MAC Chrome. Did you find a solution?
Issue reproduced for me as well. --use-file-for-fake-audio-capture doesn't work for 79 version of chrome on Mac OS. Sample audio isn't playing. I verified it on 76 version and works fine. Issue isn't related cypress, it is related to Chrome.
To output audio to speakers when using --use-fake-file-for-audio-capture
flag try using AudioContext
MediaStreamAudioSourceNode
or HTML <audio>
element
navigator.mediaDevices.getUserMedia({audio: true})
.then(stream => {
const audio = new Audio();
audio.autoplay = true;
audio.srcObject = stream;
});
navigator.mediaDevices.getUserMedia({audio: true})
.then(mediaStream => {
const ac = new AudioContext();
const source = ac.createMediaStreamSource(mediaStream);
source.connect(ac.destination);
});
Command line
chromium-browser --allow-file-access-from-files --autoplay-policy=no-user-gesture-required --use-fake-device-for-media-stream --use-fake-ui-for-media-stream --use-file-for-fake-audio-capture=$HOME/test.wav%noloop --user-data-dir=$HOME/test 'file:///home/user/testUseFileForFakeAudioCaptureChromium.html'
Tested at Chromium 80.0.3987.7 (32-bit) *nix (both file:
protocol and launching Chromium point to "https://github.com"
and running the code at console
).
To test download attached .txt
file, save as .html
, adjust paths at above command.
Sorry for the late reply. It looks fail to play audio. But there is no error logs.
BTW, I ran @guest271314's scripts on Mac, and I got error message. I put test.wav to a target path, but fail to read it.
$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version
Google Chrome 79.0.3945.88
$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--allow-file-access-from-files \
--autoplay-policy=no-user-gesture-required \
--use-fake-device-for-media-stream \
--use-fake-ui-for-media-stream \
--use-file-for-fake-audio-capture=$HOME/test/test.wav \
--user-data-dir=$HOME/test/data \
file://$HOME/test/testUseFileForFakeAudioCaptureChromium.html
[39131:86787:0104/000139.036863:ERROR:simple_sources.cc(30)] Failed to read /Users/xxxx/test/test.wav as input to the fake device.
Can you upload the wav
file that you are testing here or print the output of mediainfo test.wav
or mkvmerge -J test.wav
? The path to the file or URL to load should be a string.
I think its an issue with chromium and not cypress. I created a bug report in their issue tracker.
https://bugs.chromium.org/p/chromium/issues/detail?id=1032604
Since this issue hasn't had activity in a while, we'll close the issue until we can confirm this is still happening. Please comment if there is new information to provide concerning the original issue and we'd be happy to reopen.
Did anyone manage to get this working (found some workaround)?
according to https://bugs.chromium.org/p/chromium/issues/detail?id=1032604#c37 plugin/index.js add chrome args "--no-sandbox" demo code:
on('before:browser:launch', (browser = {}, launchOptions = { args: [] }) => {
if (browser.name === 'chrome') {
// https://bugs.chromium.org/p/chromium/issues/detail?id=1032604#c37
launchOptions.args.push('--no-sandbox')
launchOptions.args.push('--allow-file-access-from-files')
launchOptions.args.push('--use-fake-ui-for-media-stream')
launchOptions.args.push('--use-fake-device-for-media-stream')
// mp3 not work
launchOptions.args.push('--use-file-for-fake-audio-capture=tests/fixtures/hello.wav')
}
return launchOptions
})
@loszer Adding --no-sandbox
worked a treat for us, thanks for sharing the workaround.
Current behavior:
I use
--use-file-for-fake-audio-capture
for testing getUserMedia behaviour on Chrome. https://github.com/cypress-io/cypress/issues/4160But cypress v3.5.0 and v3.6.0,
--use-file-for-fake-audio-capture
doesn't work it.Desired behavior:
--use-file-for-fake-audio-capture
works on Chrome.Steps to reproduce: (app code and test code)
and args output
I tried to absolute wav file path, but it doesn't work too.
Versions
Cypress v3.5.0, 3.6.0 OS : macOS 10.15 Chrome 78.0.3904.87, 79.0.3945.16
following version worked fine Cypress v3.4.1 OS : macOS 10.15 Chrome 78.0.3904.87