Pianobar (Pandora Radio) Remote Control
I'm writing an Android app to remotely control
pianobar (running on the RPi, for example) over a Wi-Fi connection. Pianobar
is an unofficial Pandora Radio client that is easy to setup with a proxy to listen to Pandora from anywhere in the world (see
this Instructables for a step by step guide for setting up pianobar outside the US).
It supports skip, play/pause (auto-pause on incoming call), volume control, cover art, current station
and track/artist/album, loving and banning songs, station list, create and delete stations,
progress bar (remaining/total time), next song,
getting localized buy links for current album and fetching artist information from last.fm.
Mainly tested on Android 2.3.6 (should work on 2.3+). Here are some screenshots
(Creds to Naeki-Design@deviantart for icons and Ed for beta testing):
Pianobar was never made for being remotely controlled and the solution isn't the very prettiest, but it does work
fairly well in it's current state (tested with Android 2.3.6, should work with 2.3+) and I'm still
developing it to improve it's functions further.
If anyone is interested in helping out with the development, please
contact me.
Feel free to ask any questions if you have any problems/suggestions/comments as well.
Known issues:
The solution (FIFO over SSH) itself isn't the prettiest. Pianobar wasn't made for being remotely controlled
The progress bar is a bit slow (misses a second every now and then)
Latest updates:
(130404) v. 1.4.2 Bug fix: fixed a bug that caused playback to be paused after canceling some dialogs
(130328) v. 1.4.1 New feature: get localized buy links for current album from last.fm (the magnifying glass)
(130328) v. 1.4.1 A couple of bug fixes, nicer requests to last.fm
(130326) v. 1.4
NOTE! New event command file (copy from below) is necessary for version 1.4+ to function well
(130326) v. 1.4 New feature: Create stations from genres
(130326) v. 1.4 New feature: Display current album
(130324) v. 1.3.5 Button text changed on SSH login to make it more clear that the app will start pianobar
(130324) v. 1.3.5 Minor bug fix with the progress bar
(130321) v. 1.3.4 Several bug fixes. Proper handling of all network activity (= more stable)
(130320) v. 1.3.3 Bug fix: station list wouldn't work properly on (some?) Android 4 devices, should work now
(130320) v. 1.3.3 Port number check on SSH login screen
(130316) v. 1.3.2 Better shutdown function and error handling
(130305) v. 1.3.1 Several bug fixes
(130301) v. 1.3 New feature: create station from currently playing artist or song
(130301) v. 1.3 Bug fix: fixed a layout issue with the progress bar on some devices
Download/Install/Setup
You can
download the app here or
here if you are using an Android phone (or
here for an off-market apk).
Required permissions are Network Communication (to connect to pianobar and fetch cover art) and Phone Calls (to automatically pause on incoming phone call).
In order for the app to work you need to have an SSH server up and running on the music server,
this is installed and set up as default on a Raspbian distro and the login details in the app
are pre-set for Raspbian, but you can of course use any Linux distro (should work on Mac as well, install pianobar
with MacPorts/Homebrew and follow the instructions below). If your server is on a different system
you need to get SSH working and change the login details when you start the app,
contact
me with information about your server if you need help setting it up
.
Install pianobar on the server, for Debian based distros - open up a terminal (shell) and write:
sudo apt-get install pianobar
Then set up a config file for pianobar:
nano ~/.config/pianobar/config
My config file looks like this, the login details (to Pandora) are necessary for the app to function, as well as the full path
to the event command file (change the username "pi" to suit your setup). See "man pianobar" for other options:
control_proxy = http://165.225.xxx.xxx:80
#I'm not in the US so I need a proxy to use pianobar, delete the line above if you are
tls_fingerprint = 2D0AFDAFA16F4B5C0A43F3CB1D4752F9535507C0
user = myemail@mail.com
password = mypassword
event_command = /home/pi/.config/pianobar/eventcommand.sh
Make the event command file (same path as in the config file above):
nano ~/.config/pianobar/eventcommand.sh
And paste the following code (part of the code has
been taken from Bruce Connors work with
control-pianobar):
#!/bin/bash
fold="$HOME/.config/pianobar"
stl="$fold/stationlist"
ctlf="$fold/ctl"
nowplaying="$fold/nowplaying"
while read L; do
k="`echo "$L" | cut -d '=' -f 1`"
v="`echo "$L" | cut -d '=' -f 2`"
export "$k=$v"
done < <(grep -e '^\(title\|artist\|album\|stationName\|pRet\|pRetStr\|wRet\|wRetStr\|songDuration\|songPlayed\|rating\|songDuration\|songPlayed\|coverArt\|stationCount\|station[0-9]\+\)=' /dev/stdin)
case "$1" in
songstart)
echo -e "$artist \n$title \n$stationName \n$rating \n$coverArt \n$album" > "$nowplaying"
;;
songlove)
echo -e "$artist \n$title \n$stationName \n$rating \n$coverArt \n$album" > "$nowplaying"
;;
songban)
echo -e "" > "$nowplaing"
;;
usergetstations)
if [[ $stationCount -gt 0 ]]; then
rm -f "$stl"
for stnum in $(seq 0 $(($stationCount-1))); do
echo "$stnum) "$(eval "echo \$station$stnum") >> "$stl"
done
fi
;;
stationcreate)
if [[ $stationCount -gt 0 ]]; then
rm -f "$stl"
for stnum in $(seq 0 $(($stationCount-1))); do
echo "$stnum) "$(eval "echo \$station$stnum") >> "$stl"
done
fi
;;
stationaddgenre)
if [[ $stationCount -gt 0 ]]; then
rm -f "$stl"
for stnum in $(seq 0 $(($stationCount-1))); do
echo "$stnum) "$(eval "echo \$station$stnum") >> "$stl"
done
fi
;;
songexplain)
if [[ $stationCount -gt 0 ]]; then
rm -f "$stl"
for stnum in $(seq 0 $(($stationCount-1))); do
echo "$stnum) "$(eval "echo \$station$stnum") >> "$stl"
done
fi
;;
stationaddshared)
if [[ $stationCount -gt 0 ]]; then
rm -f "$stl"
for stnum in $(seq 0 $(($stationCount-1))); do
echo "$stnum) "$(eval "echo \$station$stnum") >> "$stl"
done
fi
;;
stationdelete)
if [[ $stationCount -gt 0 ]]; then
rm -f "$stl"
for stnum in $(seq 0 $(($stationCount-1))); do
echo "$stnum) "$(eval "echo \$station$stnum") >> "$stl"
done
fi
echo -e "" > "$nowplaying"
;;
esac
Make the event command file executable:
chmod +x ~/.config/pianobar/eventcommand.sh
Finally make a FIFO that receives the commands:
mkfifo ~/.config/pianobar/ctl
Test the setup by running the command "pianobar".
NOTE! Pianobar should not be started manually when you use the app (some functions won't work),
after logging in the app will start pianobar automatically (unless it's already running).
Pandora One (high quality audio)
If you have a Pandora One account (for 192kbit MP3) you need to download the latest version of pianobar
from the git repository:
git clone https://github.com/PromyLOPh/pianobar.git
Install the dependencies:
sudo apt-get install libao-dev libmad0-dev libfaad-dev libgnutls-dev libjson0-dev libgcrypt11-dev
Download
this patch (click "Download Gist"),
copy it to the pianobar folder
that was created when you cloned the git repository (default is: "cp gnutls.patch ~/pianobar"), go to that folder ("cd ~/pianobar")
and write:
git apply gnutls.patch && make && sudo make install
And add this to your config file (remove any double entries, like the tls_fingerprint if you have set it up before):
audio_quality = high
rpc_host = internal-tuner.pandora.com
partner_user = pandora one
partner_password = TVCKIBGS9AO9TSYLNNFUML0743LH82D
device = D01
encrypt_password = 2%3WCL*JU$MP]4
decrypt_password = U#IO$RZPAB%VX2
tls_fingerprint = B0A1EB460B1B6F33A1B6CB500C6523CB2E6EC946