Reputation: 21
I need to play .mp3 file in a python script on a bluetooth device connected to my Raspberry Pi 4.
I managed to play the file through headphones connected directly to my Pi's 3.5mm jack audio port using this command in command line:
omxplayer -o local audio_file.mp3
Also I managed to play the file from python script with:
os.system("omxplayer -o local audio_file.mp3")
But I need to play this .mp3 file through bluetooth speaker connected to Pi. I tried with two bluetooth devices, but no luck. Using
omxplayer -o hdmi audio_file.mp3
or
omxplayer -o alsa audio_file.mp3
don't work at all. I don't get any audio through hdmi or any bluetooth device connected to Raspberry Pi.
Using
omxplayer -o both audio_file.mp3
I only get sound from the headphones again, but this time in a really bad audio quality, but nothing on my hdmi or bluetooth device.
I have to mention that playing the audio file using the Raspberry Pi OS GUI with preinstalled VLC media player is working perfectly with any device that I select as audio output, even hdmi and bluetooth.
Upvotes: 0
Views: 1677