0

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.

Catalina
  • 21
  • 4
  • When you do `-o alsa` you need to specify the exact device. with `-o alsa:`. https://www.raspberrypi.org/documentation/raspbian/applications/omxplayer.md – ukBaz Jun 27 '21 at 20:43
  • @ukBaz could you please explain in more detail how to use this option? The documentation does not explain how to use it. For example, how should we find the correct string to use in place of ? – Alex Spurling Jan 05 '22 at 21:40
  • OMXPlayer has been deprecated in the latest RPi OS release. If you are running Bullseye, VLC is now the recommended alternative. To get the list of device then it is `LANG=C pactl list | grep -A2 'Source #' | grep 'Name: ' | cut -d" " -f2`. This is from https://www.freedesktop.org/wiki/Software/PulseAudio/FAQ/ – ukBaz Jan 05 '22 at 22:18

0 Answers0