Raspberry Pi Pandora Player

From Vinny Huckaba
Jump to: navigation, search

Using the Raspberry Pi to play Pandora One automatically upon boot.

https://github.com/prattmic/pianobar

Install Raspian Base

Install git

git clone git://github.com/prattmic/pianobar.git

apt-get install libao-dev libmad0-dev libfaad-dev libgnutls-dev libjson0-dev libgcrypt11-dev

cd into pianobar and make, make install

create your config file in ~/.config/pianobar/config

user = "username@mail.com"

password = "pandorpassword"

audio_quality = high

autostart_station = "whatever station you want to start on"

fifo = /tmp/pianobar

tls_fingerprint = 2D0AFDAFA16F4B5C0A43F3CB1D4752F9535507C0

audio_quality = high

create a shell script to launch it in a screen session and add to rc.local or ./config/autostart

#!/bin/bash

screen -dmS pianobar bash -c '/usr/local/bin/pianobar; exec bash'

Very Simple Web front end for internal use only.

Install Nginx and php support.

index.php

<a href="control.php?musicon=true">Play</a>

<a href="control.php?next=true">Next</a>

<a href="control.php?pause=true">Pause</a>

<a href="control.php?quit=true">Quit</a>

pianobar.php

if ($_GET['musicon']) {

 exec("sudo -u pi screen -x music -X stuff 'q\r' ");
 exec("sudo -u pi pkill pianobar");
 exec("sudo -u pi screen -x music -X stuff 'pianobar\r' ");

}


if ($_GET['next']) {

 exec("sudo -u pi screen -x music -X stuff 'n' ");

}

if ($_GET['pause']) {

 exec("sudo -u pi screen -x music -X stuff 'p' ");

}

if ($_GET['quit']) {

 exec("sudo -u pi screen -x music -X stuff 'q' ");
 exec("sudo -u pi pkill pianobar");

}

You will need to give www-data sudo privs, very insecure!

Personal tools