Page 1 of 2

Use bluetooth audio on Raspberry PI

Posted: Monday 10 August 2015 12:30
by pvm
I created a wiki page on bluetooth audio on raspberry pi.
This currently shows how to play an mp3 file using bluetooth

I hope to extend this with information on domoticz integration and on making domoticz talk using google translate (hope some of you can help)
http://domoticz.com/wiki/BTAudio

Re: Use bluetooth audio on Raspberry PI

Posted: Monday 10 August 2015 13:10
by ThinkPad

Re: Use bluetooth audio on Raspberry PI

Posted: Monday 10 August 2015 13:15
by pvm
Yes, i posted a link in that topic, the topic you mention is about pimusicbox, requiring an extra pi

Re: Use bluetooth audio on Raspberry PI

Posted: Monday 10 August 2015 15:50
by Heisenberg
Thnx pvm!
I followed the wiki and was wondering if it's possible to play a radio stream of mp3 file.
I tried the following url stream but it doesn't work:

Code: Select all

pi@domoticzpi ~ $ mplayer -ao alsa:device=bluetooth http://vtuner.com/setupapp/guide/asp/func/dynampls.asp?link=1&id=25743 -softvol -volume 10 -af resample=22100:0:0
[1] 3412
-bash: -softvol: command not found
edit: the url stream wasn't correct. I tried another stream and it works! :)
But how to execute and stop the stream when using a (virtual) switch within domoticz?

Re: Use bluetooth audio on Raspberry PI

Posted: Wednesday 12 August 2015 12:20
by pvm
I updated the wiki with:
edit the mplayer configuration file to prevent loading lyrics (which is not needed and reports errors on my machine sudo nano /etc/mplayer/mplayer.conf and add (top top)
nolirc=yes

Re: Use bluetooth audio on Raspberry PI

Posted: Wednesday 12 August 2015 12:21
by pvm
Heisenberg wrote: edit: the url stream wasn't correct. I tried another stream and it works! :)
But how to execute and stop the stream when using a (virtual) switch within domoticz?
You can create a script with the command to play audio and execute that from within domoticz (did not try yet). You will need the .asoundrc file in your /root directory

Re: Use bluetooth audio on Raspberry PI

Posted: Saturday 05 September 2015 8:07
by pvm
Updated the part on google translate to let domoticz speak

Re: Use bluetooth audio on Raspberry PI

Posted: Thursday 17 September 2015 20:01
by marigo
How do you keep the bluetooth device connected (paired) to the raspberry or Domoticz.

When the bluetooth speaker is idle I hear: "the bluetooth device is ready to pair". If I run a script with a sound file within, then it pairs again, but then you hear: "the bluetooth device is connected".

Does someone have a solution for this issue?

Re: Use bluetooth audio on Raspberry PI

Posted: Thursday 17 September 2015 20:41
by pvm
I can only share my results...:
My speaker sounds 'pingpong' to identify it is connected and after the speech it waits 20 seconds and disconnects with a 'pongping' sound. It does however reconnect the next time and the next and ...
Sounds like your device is bahaving the same but the speech identifying it is connected is disturbing.... I do not now wether it is possible to keep it connected al the time....

Re: Use bluetooth audio on Raspberry PI

Posted: Thursday 17 September 2015 21:00
by marigo
Yes, I have the same behavior. It does work, but every time you have to trigger it. I have small mp3 files to inform about events within Domoticz, but when the device every time have to pair again, I can't hear the mp3 files.

Well, I think it is possible to stay paired, but I didn't found it yet. :) If I find it I'll will post it here.

Thank you for your WiKi

EDIT: I found this setup in ~/.asoundrc to direct all sound through the bluetooth device. (It's not to stay paired, but I think it's handy)

Code: Select all

## Redirect all sound via Bluetooth
pcm.!default {
        type bluetooth
        device 6E:C9:E9:88:DE:6C # change this MAC address to your speakers address
        profile "auto"
}

Re: Use bluetooth audio on Raspberry PI

Posted: Thursday 17 September 2015 21:22
by pvm
When this works correctly it sounds like a good update to the u are allowed to update / improve things :)

Re: Use bluetooth audio on Raspberry PI

Posted: Friday 18 September 2015 18:45
by Derik
mmm
Is there a option to play a internet radio stream?

And active this with a script/button...
Button 1 radio 3
Button 2 Qmusic
etc

Re: Use bluetooth audio on Raspberry PI

Posted: Saturday 19 September 2015 13:34
by pvm
Yes, specify the url you want to play in a script (start player in background with &), start that from the on script for the switch.
Create an off script to kill the media player

Re: Use bluetooth audio on Raspberry PI

Posted: Sunday 20 September 2015 10:29
by Heisenberg
I created a musicplay.sh script to play a stream. This works fine.

Code: Select all


#!/bin/sh
mplayer -ao alsa:device=bluetooth http://stream1.slowradio.com -softvol -volume 5 -af resample=22100:0:0
However I can't stop this with musicstop.sh. Any suggestions?

Code: Select all

#!/bin/sh
mplayer -slave -quiet


Re: Use bluetooth audio on Raspberry PI

Posted: Sunday 20 September 2015 11:17
by pvm
The stop script should kill the shmplayer. ('man kill' for instructions)

Re: Use bluetooth audio on Raspberry PI

Posted: Monday 21 September 2015 23:38
by deennoo
Why don't you try to stream full ALSA sound ? (Microphone too, this way, no connections interupt)

Re: Use bluetooth audio on Raspberry PI

Posted: Tuesday 22 September 2015 14:41
by pluggin
When play mp3 files loose/cut the last part of the file only usign bluetooth speakers other way play fine. Any clues?

Re: Use bluetooth audio on Raspberry PI

Posted: Saturday 03 October 2015 8:19
by Derik
Is there a option to play/switch to a internet stream?
Activate 1 dummy, to play mp3
A other dummy switch. To play a internet stream..

And is it possible to adjust the volume?

Re: Use bluetooth audio on Raspberry PI

Posted: Saturday 03 October 2015 8:52
by pvm
pluggin wrote:When play mp3 files loose/cut the last part of the file only usign bluetooth speakers other way play fine. Any clues?
I guess this is done by your Bluetooth device, if you play an silent (or other not silent) not directly after it, what happens then?

Re: Use bluetooth audio on Raspberry PI

Posted: Saturday 03 October 2015 8:53
by pvm
Derik wrote:Is there a option to play/switch to a internet stream?
Activate 1 dummy, to play mp3
A other dummy switch. To play a internet stream..

And is it possible to adjust the volume?
See post 14 a few above this one