Then to get music playing over the USB sound card all I really had to do was run pactl load-module module-udev-detect. My sound card is detected and is set as the default sink instantly (I guess because it is the only sink available on my RPi2) and my Bluetooth streamed music starts playing over my speakers, yay! At the same time I can play anything using Kodi and Kodi's sound is passed through over HDMI while simultaneously streaming Bluetooth music, exactly what I wanted to achieve.
To automatically detect my sound card at boot I added pactl load-module module-udev-detect to autostart.sh. Funny how that was really all I had to do to get my ideal setup working.
Wow I have been wanting this for years. I found your post and it worked a treat.
For clarity, I've been using Kodi on an RPI2 for years with a Creative USB sound card. Airplay has been mostly ok - but a bit unstable - and streaming from Android has been impossible.
To get Android (and Apple for that matter) streaming to the RPI's Bluetooth, do the following:
- Pair the phone using Settings -> Libreelec -> Bluetooth
- Change the Audio output device to PULSE in Settings -> System -> Audio. When you change this the audio will stop working until the rest of this procedure is completed so don't be alarmed
- Get the network IP Address from Settings -> System information
- SSH into Kodi using the IP address and login with user root pw libreelec
- nano /storage/.config/autostart.sh
- paste the following:
pactl load-module module-udev-detect - Save the file (CTRL-X -> y -> [ENTER])
- Reboot the RPI
- Reconnect Bluetooth from your phone
- Start streaming from Spotify or any other app, as you would with any bluetooth speaker or headset
- You can still play audio as usual from Core or Yatse but if you are streaming at the same time, the audio will mix so stick to using one or the other at any given time
- Pros of playing from Core or Yatse are guaranteed audio quality and access to your library, playlists etc. Once you start playing audio your phone is no longer required; the music will play even if the phone leaves wifi or bluetooth range or is switched off
- Streaming via bluetooth is convenient. Downsides are that the phone must stream audio from the Internet as long as it is playing (meaning battery, bandwidth) and the phone must remain in bluetooth range or the audio will get choppy and eventually disconnect. Audio quality is not guaranteed as compression is likely. Sounds pretty satisfactory me my old ears though!
I hope this helps other people who want to get this working. It really only takes a few minutes and has awesome payback. I'm unsure if the autostart.sh changes will survive an upgrade - time will tell.
Happy me