I have a service running on Raspbian OS 11 lite on a Raspberry 3, which should play audio for me.
[Unit]
Description=My script to monitor the shutdown button
After=multi-user.target
[Service]
ExecStart=/usr/bin/python /home/pi/Radio/Radio/main.py
User=root
Group=root
[Install]
WantedBy=multi-user.target
The service is running and interacting with the user by reading his input. But as soon as it should play music, I always get the following error:
Oct 10 18:22:57 raspberrypiradio python[4180]: [755aa250] main audio output error: Audio output failed
Oct 10 18:22:57 raspberrypiradio python[4180]: [755aa250] main audio output error: The audio device "default" could not be used:
Oct 10 18:22:57 raspberrypiradio python[4180]: Connection refused.
Oct 10 18:22:57 raspberrypiradio python[4180]: [755aa250] main audio output error: module not functional
Oct 10 18:22:57 raspberrypiradio python[4180]: [7312c1f0] main decoder error: failed to create audio output
Oct 10 18:24:00 raspberrypiradio python[4180]: [75591ca8] vlcpulse audio output error: PulseAudio server connection failure: Access denied
Oct 10 18:24:01 raspberrypiradio python[4180]: [75588cb0] vlcpulse audio output error: PulseAudio server connection failure: Access denied
Oct 10 18:24:01 raspberrypiradio python[4180]: [73d01830] http stream error: cannot resolve stream.rockantenne.de: System error
Oct 10 18:24:01 raspberrypiradio python[4180]: [73d01830] access stream error: HTTP connection failure
Oct 10 18:24:01 raspberrypiradio python[4180]: [73d01830] http stream error: cannot connect to stream.rockantenne.de:80
When I am playing the main.py file directly via terminal, everything is working. I am playing the sound in the python file via vlc.
I am using a service, because I want the main.py to run all the time. Especially after rebooting the system.