Playing audio not working in headless mode (using Chrome)
See original GitHub issueI’m trying to play spotify via puppeteer. Because Chromium seems to not like audio file, I use chrome.
In headful mode, everything work well, but when I switch to headless mode, the song doesn’t play at all (as if I was using Chromium??).
I though headless would had the same feature than headfull. I also tested with Edge but same problem.
Here is my code
var puppeteer = require('puppeteer');
var util = require("./util.js");
async function initBrowser(){
let browser = await puppeteer.launch({
headless: false, //permet de voir
slowMo: 15,
executablePath: 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
//
//args: (url)?[ `--proxy-server=${url}`]:[]
});
return browser;
}
exports.main = async function(){
let browser = await initBrowser();
let webPage = await browser.newPage();
await webPage.goto("https://accounts.spotify.com/en/login/", { waitUntil: "load", timeout: 30000});
//login
await webPage.type('#login-username', 'LOGIN');
await webPage.type('#login-password', 'PSWD');
await webPage.click('#login-button');
await util.sleep(1000);
//music
await webPage.goto("https://open.spotify.com/artist/3nFkdlSjzX9mRTtwJOzDYB", { waitUntil: "load", timeout: 30000});
await util.sleep(2500);
await webPage.click('#onetrust-accept-btn-handler'); //accept cookie
await util.sleep(1000);
await webPage.click('div[data-testid="action-bar-row"] button[data-testid="play-button"]'); //click on play
await webPage.screenshot({ path: 'test.png' })
}
Am I really still using Chrome in headless mode?
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Microphone access in headless mode - Google Groups
I've allowed microphone access and have no trouble. Using the same user profile I launch a headless instance of chrome and the microphone...
Read more >Headless Browser: Audio Output to Pulseaudio - Ask Ubuntu
I've managed to get this working by running Puppeteer, rather than trying to wrangle Chromium from the command line.
Read more >Try These Fixes When Your Sound is Not Working in Chrome
How to Fix Sound Not Working in Chrome on Mac? · Open System Preferences. · Next, click on Sound. · Select the Output...
Read more >application is not able to record sound while the selenium ...
I created a selenium script that clicks on the element to record the sound. It works perfectly except in headless mode. The script...
Read more >Getting Started with Headless Chrome - Chrome Developers
--headless \ # Runs Chrome in headless mode. --disable-gpu \ # Temporarily needed if running on Windows. ... https://www.chromestatus.com # URL to ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@theDavidBarton FWIW I filed this Chromium bug https://bugs.chromium.org/p/chromium/issues/detail?id=1221905.
We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!