question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Playing audio not working in headless mode (using Chrome)

See original GitHub issue

I’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:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
guest271314commented, Jun 20, 2021
0reactions
stale[bot]commented, Jul 24, 2022

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found