I’m having a tough time playing audio from a React App in chromium, through a DAC (based on the discontinued PhatDAC from PiMoroni) on a custom Hat attached to a Raspberry Pi 4 with
Define DT parameters:i2c_arm=on", "spi=on", "audio=off and
Enable DT Params:hifiberry-dac. I am building my image based on the BalenaBlocks browser. But I included the pimoroni setup script found through their setup page. The script isn’t intended to work with Pi4 arch, but I hacked line 197, to be
IS_ARMHF=true, and that seems to let the setup script do its thing. Guessing this is because of the arch differences between Pi3 (what we originally designed the hat for) and Pi4 (which we upgraded our next fleet to). But, the audio still will be enabled and play through the attached speak, except…
When I’m running the React App inside of a Balena device, the speaker is popping at varying intervals (I observed a correlation to when the React App is loading pages or doing something in the background) and the Audio will cut in an out. But most frustrating of all is video content loaded inside of the react app wont play any audio unless it sits for awhile, (guessing the entire file finished loading). This files are mp4, streaming from an on prem asset server.
The strange thing is when I point the chromium browser directly to the file on our asset server, the audio will play along with the video content as soon as its available enough to stream. But when the React App loads the same video, it will not play. Also, in all cases there is regular popping of the speaker.
When I load this app into chromium on a Pi4 with a normal raspbian OS (not balena’d), the video inside the react app plays normally, and no popping of the speaker.
After much searching around on forums, I came across one board saying that i could use BalenaSound and send the audio from the container running chromium into BalenaSound containers, with the
AUDIO_OUTPUT:DAC set on the Device environment variables. and setting up the Audio Block, as called for in this The sound is perfect, without any popping, and the video in the React App plays audio, except its about 2 seconds delayed. Saw a forum (this one) where another person had this issue. Seems to have gone unresolved.
I’ve also tried the more simple approach of just using the BalenaBlocks browser, with turning on the AudioBlock, and setting
Define DT Overlays:hifiberry-dac. But also get regular popping of the speaker through the react app, and the audio from videos inside the react app never plays (vs will play after a long wait), but it will play when pointed directly to the file on the asset server.
Other small sound effects will play, only the audio of a video in the React App has consistent issues.