I've had a hard time bringing bluetooth to work on a Raspberry Pi 5 with Ubuntu 24.04 using Pipewire as audio backend. Maybe you run into the same situation and find this helpful.
With the common tutorials on how to enable a bluetooth speaker connection on Ubuntu, there were the following problems for my combination of Ubuntu 24.04 on a Raspberry Pi 5 and using PipeWire (as of July 2024):
- either the audio quality was fine but the connection automatically disconnects after a few seconds
- or the connection does not disconnect, but the audio begins to stutter extremely after 60 to 90 seconds of audio played
Since Ubuntu 22.10, PipeWire is the default soundserver on Ubuntu, so trying to use Bluetooth with PulseAudio as soundserver would mean to uninstall the recommended default and reconfigure the system.