dbyers
Posts: 4
Joined: Sun Jan 04, 2015 4:51 pm

Controlling MPlayer using AVRCP via Bluetooth

Sun Jan 04, 2015 4:55 pm

Hi,

I'm trying to create an iPod with my Pi basically. Although I can get audio to stream via Bluetooth to my car stereo, I'm unable to get the tracks to change/pause/ff/rw etc by using the buttons on my car stereo. I believe I need to use AVRCP but I'm not sure how to configure it.

I have a Bluetooth speaker with track control buttons for testing (so I don't have to be sitting in my car with my netbook and Pi connected!

I'd appreciate any suggestions anyone might have?

Many thanks

User avatar
Douglas6
Posts: 4403
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Controlling MPlayer using AVRCP via Bluetooth

Sun Jan 04, 2015 6:35 pm

If you are using BlueZ 4.99 (the standard Raspian repo version) you may be out of luck. It has limited AVRCP support (volume only, I believe). If you want to build and install 5.x, I think you'll also need PulseAudio 5, as BlueZ 5 dropped ALSA support. I've had some success with this set-up as an A2DP client with an Android server, but it just might work with the Pi as a server.

Then it should be a simple bit of Python coding to catch the AVRCP D-Bus signals (for some interpretation of 'simple').

fruitoftheloom
Posts: 17247
Joined: Tue Mar 25, 2014 12:40 pm

Re: Controlling MPlayer using AVRCP via Bluetooth

Sun Jan 04, 2015 7:00 pm

fyi Raspbian Jessie Testing has Bluez version 5.xx

https://packages.debian.org/jessie/bluez
Last edited by fruitoftheloom on Sun Jan 04, 2015 7:35 pm, edited 1 time in total.
Adieu

User avatar
Douglas6
Posts: 4403
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Controlling MPlayer using AVRCP via Bluetooth

Sun Jan 04, 2015 7:18 pm

fruitoftheloom wrote:fyi Raspbian Jessie Testing has Bluez version 5.xx
Good point. But PulseAudio still needs upgrading to version 5. I find it easier to stick with Wheezy, but Jessie is an option.

fruitoftheloom
Posts: 17247
Joined: Tue Mar 25, 2014 12:40 pm

Re: Controlling MPlayer using AVRCP via Bluetooth

Sun Jan 04, 2015 7:33 pm

Douglas6 wrote:
fruitoftheloom wrote:fyi Raspbian Jessie Testing has Bluez version 5.xx
Good point. But PulseAudio still needs upgrading to version 5. I find it easier to stick with Wheezy, but Jessie is an option.
fyi Raspbian Jessie Testing has PulseAudio version 5.x

https://packages.debian.org/jessie/pulseaudio
Adieu

User avatar
Douglas6
Posts: 4403
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Controlling MPlayer using AVRCP via Bluetooth

Sun Jan 04, 2015 7:53 pm

fruitoftheloom wrote: fyi Raspbian Jessie Testing has PulseAudio version 5.x

https://packages.debian.org/jessie/pulseaudio
Now that I did not know. Thank you. Last time I checked (not long ago), Jessie's PA was older, I thought. I'll have to give it a try again.

fruitoftheloom
Posts: 17247
Joined: Tue Mar 25, 2014 12:40 pm

Re: Controlling MPlayer using AVRCP via Bluetooth

Sun Jan 04, 2015 7:55 pm

Douglas6 wrote:
fruitoftheloom wrote: fyi Raspbian Jessie Testing has PulseAudio version 5.x

https://packages.debian.org/jessie/pulseaudio
Now that I did not know. Thank you. Last time I checked (not long ago), Jessie's PA was older, I thought. I'll have to give it a try again.
As Jessie Testing is at a freeze stage prior to release the developers have put in many updated packages ;)
Adieu

dbyers
Posts: 4
Joined: Sun Jan 04, 2015 4:51 pm

Re: Controlling MPlayer using AVRCP via Bluetooth

Sun Jan 04, 2015 7:57 pm

Ok thank you guys. Now, the question is, how do I get it, install it and use it? Sorry I'm a bit of a noob I'm afraid!

dbyers
Posts: 4
Joined: Sun Jan 04, 2015 4:51 pm

Re: Controlling MPlayer using AVRCP via Bluetooth

Wed Jan 07, 2015 10:19 am

Ok, so I've installed Jessie and checked the pulseaudio and bluez versions:

[email protected] ~ $ sudo apt-cache show pulseaudio | grep -i version
Version: 5.0-13
[email protected] ~ $ sudo apt-cache show bluez | grep -i version
Version: 5.23-2

I've got everything setup so that I can now play music through my test Bluetooth speakers, but I still can't skip tracks using the buttons on the speakers. I have no doubt I've forgotten some configuration somewhere along the line since I was trying to use ALSA before and I'm not used to using PulseAudio.

the playback is smooth though, which is promising!

Can anyone get me going in the right direction again?

Many thanks.

dbyers
Posts: 4
Joined: Sun Jan 04, 2015 4:51 pm

Re: Controlling MPlayer using AVRCP via Bluetooth

Wed Jan 07, 2015 12:57 pm

Ok, I think I'm getting closer - at least I know that the button press events are getting into my Pi...!

[email protected] / $ sudo evtest /dev/input/event0
Input driver version is 1.0.1
Input device ID: bus 0x5 vendor 0x0 product 0x0 version 0x0
Input device name: "00:75:58:EB:8B:34"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 2 (KEY_1)
Event code 3 (KEY_2)
Event code 4 (KEY_3)
Event code 5 (KEY_4)
Event code 6 (KEY_5)
Event code 7 (KEY_6)
Event code 8 (KEY_7)
Event code 9 (KEY_8)
Event code 10 (KEY_9)
Event code 11 (KEY_0)
Event code 28 (KEY_ENTER)
Event code 52 (KEY_DOT)
Event code 59 (KEY_F1)
Event code 60 (KEY_F2)
Event code 61 (KEY_F3)
Event code 62 (KEY_F4)
Event code 63 (KEY_F5)
Event code 64 (KEY_F6)
Event code 65 (KEY_F7)
Event code 66 (KEY_F8)
Event code 67 (KEY_F9)
Event code 103 (KEY_UP)
Event code 105 (KEY_LEFT)
Event code 106 (KEY_RIGHT)
Event code 108 (KEY_DOWN)
Event code 113 (KEY_MUTE)
Event code 114 (KEY_VOLUMEDOWN)
Event code 115 (KEY_VOLUMEUP)
Event code 138 (KEY_HELP)
Event code 139 (KEY_MENU)
Event code 163 (KEY_NEXTSONG)
Event code 165 (KEY_PREVIOUSSONG)
Event code 166 (KEY_STOPCD)
Event code 167 (KEY_RECORD)
Event code 168 (KEY_REWIND)
Event code 171 (KEY_CONFIG)
Event code 174 (KEY_EXIT)
Event code 200 (KEY_PLAYCD)
Event code 201 (KEY_PAUSECD)
Event code 208 (KEY_FASTFORWARD)
Event code 353 (KEY_SELECT)
Event code 356 (KEY_POWER2)
Event code 358 (KEY_INFO)
Event code 362 (KEY_PROGRAM)
Event code 364 (KEY_FAVORITES)
Event code 395 (KEY_LIST)
Event code 398 (KEY_RED)
Event code 399 (KEY_GREEN)
Event code 400 (KEY_YELLOW)
Event code 401 (KEY_BLUE)
Event code 402 (KEY_CHANNELUP)
Event code 403 (KEY_CHANNELDOWN)
Event code 405 (KEY_LAST)
Event type 2 (EV_REL)
Key repeat handling:
Repeat type 20 (EV_REP)
Repeat code 0 (REP_DELAY)
Value 250
Repeat code 1 (REP_PERIOD)
Value 33
Properties:
Testing ... (interrupt to exit)
I push the Bluetooth speakers track skip forward button...
Event: time 1420635327.579763, type 1 (EV_KEY), code 163 (KEY_NEXTSONG), value 1
Event: time 1420635327.579763, -------------- EV_SYN ------------
Event: time 1420635327.637055, type 1 (EV_KEY), code 163 (KEY_NEXTSONG), value 0
Event: time 1420635327.637055, -------------- EV_SYN ------------
I push the Bluetooth speakers track skip reverse button...
Event: time 1420635329.394833, type 1 (EV_KEY), code 165 (KEY_PREVIOUSSONG), value 1
Event: time 1420635329.394833, -------------- EV_SYN ------------
Event: time 1420635329.428667, type 1 (EV_KEY), code 165 (KEY_PREVIOUSSONG), value 0
Event: time 1420635329.428667, -------------- EV_SYN ------------
I push the Bluetooth speakers track play/pause button...
Event: time 1420635330.433946, type 1 (EV_KEY), code 200 (KEY_PLAYCD), value 1
Event: time 1420635330.433946, -------------- EV_SYN ------------
Event: time 1420635330.491532, type 1 (EV_KEY), code 200 (KEY_PLAYCD), value 0
Event: time 1420635330.491532, -------------- EV_SYN ------------

User avatar
Douglas6
Posts: 4403
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Controlling MPlayer using AVRCP via Bluetooth

Wed Jan 07, 2015 1:42 pm

Nicely done. It doesn't look like those keys can be mapped with mplayer, however, and key binding programs seem to require x windows. Here's one approach off the top of my head: a little Python script with evdev to detect those keys and translate and pass them along to mplayer via a fifo.

bt_noobie
Posts: 1
Joined: Thu Sep 17, 2015 11:04 pm

Re: Controlling MPlayer using AVRCP via Bluetooth

Thu Sep 17, 2015 11:17 pm

Hi everyone!
I also want similar future as OP.
I can now stream audio from phone to rpi but cannot control phone mplayer with avrcp. I have bluez 5.34 and pulseaudio 2.0. Still trying to upgrade to 5.0 as Douglas mentioned.
Were you able to make it work with Jessie's package?
I want to get metadata of current track also.
I tried bluetooth-player as mentioned by Douglas in another thread but it says no player can be found.
Also when inspecting dbus via d-feet, there is no MediaControl service there. Only the volume up down which does not seem to work.
Please help me. Im so sorry Im noob.

slimshady
Posts: 20
Joined: Thu Apr 05, 2018 1:15 pm

Re: Controlling MPlayer using AVRCP via Bluetooth

Mon Jun 04, 2018 12:24 pm

bt_noobie wrote:
Thu Sep 17, 2015 11:17 pm
Hi everyone!
I also want similar future as OP.
I can now stream audio from phone to rpi but cannot control phone mplayer with avrcp. I have bluez 5.34 and pulseaudio 2.0. Still trying to upgrade to 5.0 as Douglas mentioned.
Were you able to make it work with Jessie's package?
I want to get metadata of current track also.
I tried bluetooth-player as mentioned by Douglas in another thread but it says no player can be found.
Also when inspecting dbus via d-feet, there is no MediaControl service there. Only the volume up down which does not seem to work.
Please help me. Im so sorry Im noob.
Hello,
i'm using stretch lite and I'm trying to do the same project !
did you have any success ?

any suggestion would be appreciated !

Thanks

sidsst
Posts: 4
Joined: Mon Jun 18, 2018 6:57 am

Re: Controlling MPlayer using AVRCP via Bluetooth

Thu Jul 12, 2018 10:04 am

Please suggest on how to modify evtest to listen for specific events and act accordingly !

Thanks

Return to “Advanced users”

Who is online

Users browsing this forum: Baidu [Spider] and 8 guests