Is it possible to auto play audio

I have followed the tutorial at https://www.balena.io/blog/make-a-web-frame-with-raspberry-pi-in-30-minutes/ and have been able to get my web page to display properly when the device is booted.

My issue is now that there is a timer on my webpage that is set to go off three different times of the day. The javascript works in test, but not on the pi. I had a similar issue when I first started testing, and figured out I needed to change the setting in my chrome browser. Is there a way to do something similar here?

Thanks in advanced,

Ryan

Hello @rjoel98, I will give the project with audio a try today and I will report back once I have a solution.

Thank you

1 Like

@rjoel98 Quick question, are you trying to run the audio via the P2 jack or HDMI?

I tried using the P2 Jack and it worked fine, although the sound quality is not the best. For using the Audio Jack, it is recommended to use some sort of audio amplifier such as:

For HDMI, could you try adding in the Device Configuration the variable:

BALENA_HOST_CONFIG_hdmi_drive with value of 2.

Let me know if this helps

Cheers

@dansku To answer your question, I am using HDMI.

I tried,

But unfortunately I still have had no luck. This is a basic version of the code that I am trying to run here http://3.91.201.56/test.html
I am using javascript to check the time, and if it matches the preset time, then the audio file is played. I know that the timer aspect works, but I can’t even get the audio to autoplay on load using the autoplay function in the tag.

@rjoel98

Can you test one thing for me, if you set the WPE_URL as https://www.yout-ube.com/watch?v=fTa7CZfYZCY , does it play the audio?

Yes, it works fine. From what I can tell there are a few sites that have been whitelisted for autoplay on browsers like chrome/chromium but I need to be able to replicate this across multiple different instances and devices.

A little bit of context is that I am building a wallboard application for a chain so I need to be able to setup a unique url for each store and host the wallboard with this “timer” attached so they can see the correct information.

Hey @rjoel98,

I think the solution there is to find another method to embed the audio on the page instead of html5 as it doesn’t work.

I tested for example, embedding a video to the page and it worked fine. Keep me posted on the development!

Cheers

@dansku I went ahead and did some more research, and I have tried loading the file through iframe and javascript, I also tried changing the source to google drive, and they all work on my mac when I use Chrome, Safari, or Firefox, but nothing on the pi. Any other suggestions on how I could try loading the audio?

@dansku Also, what method did you use to embed the video? I tried just using the
<video> method but it gives me an error when I try running it on the pi. As I mentioned earlier, I am using Javascript as an alarm so I need the variable to be able to be played and paused from js.

Do you know what browser balenadash uses so I can do some more research and find out what formats are compatible?

Hey @rjoel98,

Here is an example you can test and see the video playing with audio.
https://danielandrade.net/balena/audio/

Let me know if you have any progress.

Cheers