Comments (8)
I think this should be doable using the org.bluez.MediaPlayer1 API (https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/media-api.txt) though I have never tried it.
Currently all the media controls need to be done from the connecting device and the Pi is simply an audio sink.
The MediaPlayer1 API would need a dbus client. Something similar as the current a2dp agent (https://github.com/spietika/meta-rpi-bt-dac/blob/master/recipes-connectivity/a2dp-agent/files/agent.c)
from meta-rpi-bt-dac.
There is a utility called "bluetooth-player" that comes with the BlueZ source (https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/tools/bluetooth-player.c) that implements the MediaPlayer1 API. I was able to use it from command line and control Spotify when playing music from my phone (example below, also showing song info from the phone). Though, after pause/play the next did not seem to work anymore so there probably is some debugging needed.
Currently the bluetooth-player utility is not included in the image. If you like to have a go at this, I can build a new release with it included.
[bluetooth]# next
Attempting to jump to next
Next successful
[CHG] Player /org/bluez/hci0/dev_64_A2_F9_0E_D2_55/player7 Title: Reflect The Storm
[CHG] Player /org/bluez/hci0/dev_64_A2_F9_0E_D2_55/player7 Duration: 0x03ea08
[CHG] Player /org/bluez/hci0/dev_64_A2_F9_0E_D2_55/player7 Item: /org/bluez/hci0/dev_64_A2_F9_0E_D2_55/player7/NowPlaying/item1
[CHG] Player /org/bluez/hci0/dev_64_A2_F9_0E_D2_55/player7 Album: Come Clarity (Re-issue 2014)
[CHG] Player /org/bluez/hci0/dev_64_A2_F9_0E_D2_55/player7 Artist: In Flames
[CHG] Player /org/bluez/hci0/dev_64_A2_F9_0E_D2_55/player7 NumberOfTracks: 0x000000
[CHG] Player /org/bluez/hci0/dev_64_A2_F9_0E_D2_55/player7 TrackNumber: 0x000000
[CHG] Item /org/bluez/hci0/dev_64_A2_F9_0E_D2_55/player7/NowPlaying/item1 Title: Reflect The Storm
[CHG] Item /org/bluez/hci0/dev_64_A2_F9_0E_D2_55/player7/NowPlaying/item1 Duration: 0x03ea08
[CHG] Item /org/bluez/hci0/dev_64_A2_F9_0E_D2_55/player7/NowPlaying/item1 Album: Come Clarity (Re-issue 2014)
[CHG] Item /org/bluez/hci0/dev_64_A2_F9_0E_D2_55/player7/NowPlaying/item1 Artist: In Flames
[CHG] Item /org/bluez/hci0/dev_64_A2_F9_0E_D2_55/player7/NowPlaying/item1 NumberOfTracks: 0x000000
[CHG] Item /org/bluez/hci0/dev_64_A2_F9_0E_D2_55/player7/NowPlaying/item1 TrackNumber: 0x000000
[CHG] Player /org/bluez/hci0/dev_64_A2_F9_0E_D2_55/player7 Position: 0x0000a6
[bluetooth]#
from meta-rpi-bt-dac.
I'll try making a gpio control script on a fresh install of raspbian. I wanted to do this for a while but I didn't know about this api so this should help
from meta-rpi-bt-dac.
The script I made runs on python 2.7. I included a picture that shows which pins are used for media control and I already made sure they wouldn't mess with the dac
I can't figure out how to get the MAC address to use for the dbus commands so I have to look into that more
gpio-media-control.txt
from meta-rpi-bt-dac.
I don't know how to set up the build environment but I just modified the existing image. You have to modify /usr/bin/gpio-media-control.py to manually put your phone mac address
https://www16.zippyshare.com/v/Grddlgd4/file.html
from meta-rpi-bt-dac.
Great work. What changes did you have to make to get it working? Add Python and gpio-media-control.py script and probably some init script for it? Anything else?
from meta-rpi-bt-dac.
I just added the script and the bare minimum to get python working (/usr/bin/python2.7, /usr/include/python2.7, and /usr/lib/python2.7). I just added the script to the init script for the a2dp service
from meta-rpi-bt-dac.
I built a new image with Python and GPIO library included. Moreover, I also added the bluetooth-player utility to the image.
If you have time, could you test the media control script with bluetooth-player previous
, bluetooth-player next
etc. commands in place of the current dbus-send. I think the player utility is able to figure out the MAC automatically so it would be quite generic.
from meta-rpi-bt-dac.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meta-rpi-bt-dac.