Topic: Start/Stop Pandora
I'm trying to write a script that will start and stop Pandora. Stopping it is easy enough from the Wiki, sending a "Stop" event to "MusicPlayer". However, there's no easy way to start it back up again.
Thinking a little outside the box, I created a one-time alarm set in the distant future that plays Pandora for 120 minutes. There's a couple of problems with this: 1) presumably it only plays for 120 minutes, 2) it requires someone to create and alarm and know the index of the alarm, and 3) the alarm messes with the volume.
My resulting script looks like this:
#! /bin/bash
if [ "$1" == "start" ]; then
volume=`head -1 /psp/volume`
echo '<event type="AlarmPlayer" value="ring" comment="2"/>' > /tmp/flashplayer.event
chumbyflashplayer.x -F1
# now deal with alarm messing with the volume. Yuck!
for i in {1..4}; do
curvolume=`head -1 /psp/volume`
echo $curvolume $volume
if [[ "$curvolume" -ne "$volume" ]]; then
echo '<event type="MusicPlayer" value="setVolume" comment="'$volume'"/>' > /tmp/flashplayer.event
chumbyflashplayer.x -F1
fi
sleep 1
done
fi
if [ "$cmd" == "stop" ]; then
echo '<event type="MusicPlayer" value="stop" comment=""/>' > /tmp/flashplayer.event
chumbyflashplayer.x -F1
fi
This is a horrible nastly kludge; I'm really hoping someone has a better way for me to do it. Certainly, the functionality exists to programmatically launch Pandora as the alarm is able to do it. However, I can't seem to find any easy API for doing it.
Thanks,
Scott Baker, www.smbaker.com