1

The page is exibit in a TV on a reception. When it's open we got a dialog with a button to allow the webpage to play audio. And the page refresh itself after 40 seconds.

For the most time of the day, the page is playing the sound, but sometimes, the text is updated but the sound is not heard. And it just come back after a manual refresh(F5). It seems the problem is with the browser. As the page has not user interactions, in addition tobutton to allow the sound, maybe the browser is disabling the sound?

On the manual refresh case, there was no interaction with the page, like a click, just a F5.

Currently we're using the Audio, should i try with the AudioContext?

We though the problem was with cache, so we created a auto refresh, but it wasn't enougth to resolve the problem.

i'm expecting now to find a clue about what's stopping the audio from playing

audio code:

async function playAudio(url){
    audio = new Audio(url)
    return new Promise(res => {
        audio.play()
        audio.onended = res
    })
}
13
  • 1
    Please show us the relevant code, currently I’m not at all clear what question you are asking. Is the problem that you have to wait for a user interaction to play the sound? Commented Sep 20, 2024 at 17:02
  • 1
    Have you found any information regarding this in the developer tools of the browser? Commented Sep 20, 2024 at 17:03
  • 1
    @IsraelBessa What platform are you running on this monitor? If it's just Chrome/Chromium, you can use --autoplay-policy=no-user-gesture-required when starting the browser. Commented Sep 22, 2024 at 2:10
  • 1
    Ah, just looked again and see ‘every time a client is called’. Are you creating a new element each time? If so where are you deleting it? We do need to see more context of how this is being used. Commented Sep 22, 2024 at 6:21
  • 1
    Well, the difference might be that you are creating a new element each time, but without seeing the code you use to call that function it's impossible to tell. Is there a reason you are unable to show us more of the context-code? Commented Sep 23, 2024 at 12:28

1 Answer 1

1

I managed to solve the problem by inserting the url into the list of always active sites in the browser

Chrome: Settings > Performance > Always keep these sites active

As the page has no user interaction, the browser was changing it's state to increase performance, and this was affecting the audio. Setting this configuration will stop the browser from change the page state.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.