Saturday, January 7, 2017

A simple raspberry pi Juke Box (what I have so far)

So I wanted to make a pi that will randomly select MP3 files from a directory and play them out a headphone jack.  Then I would use something like BTSync (or Risilio or whatever its called now) to push mp3's into it from a computer.  I've got the basic script that plays random tracks:



I'm just using random.choice(os.listdir()) to find a random file.  Then I use .replace to change spaces to have an escape character.  Finally I'm formulating a launch command to run it with omxplayer and executing it.

I've got a grep via os.system to see if the track is still playing and if not, moves on.  From another terminal you can run "pkill omxplayer" to terminate the track which is the same as it ending normally:



I've also got some logic that will keep the same track from playing twice, that's where it keeps picking randomTrack until it's not the same as lastRandomTrack.

During the wait I want to add buttons for the following:
1. Kill OMX player (if you just want to skip the track)
2. Kill OMX player AND move the track out of the play list (to tracks/disabled or something)
3. Safely shut down the radio for power off
4. A power switch (turns on the pi which auto launches to the radio, use the safe shutdown button before flipping it off)

More to come!

No comments:

Post a Comment