When I try and connect with bluetoothctl on command line, it connects, but no audio is played.
Both contexts are different. When you connect two Bluetooth devices together (i.e. you "pair" them) you only establish a connection between the two: network link, audio sink, audio source. If you connect your Pi to a Bluetooth audio source, it doesn't necessarily mean you want to use the new audio sink at once. You need a different command for that.
In short, under GNU/Linux in this very case:
- there is a command for pairing Bluetooth devices
- there is a command to select what audio device will play the sound
These two do not overlap.
Selecting what device plays sound is done through a dedicated application called PulseAudio daemon (a service that runs in the background), which manages sound on most GNU/Linux distributions. It doesn't control Bluetooth, the latter of which is managed by the Bluez daemon. That's why you have two separate commands.
How can I select the audio output as bluetooth from command line.
Note: I don't have PulseAudio installed on my machine so what follows might be not 100% accurate. See Arch wiki for more details about PulseAudio.
If you want to play audio through a recently paired Bluetooth audio device, here's what to do:
list audio sinks :
pacmd list-sinks | grep -E 'name:|index' . The
* locates the currently selected sink. Note what follows
name: for the Bluetooth device the Pi is connected to.
set the default audio sink :
pacmd "set-default-sink <the name of the desired BT audio sink>