O'Reilly logo

Raspberry Pi Blueprints by Dan Nixon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Scripting a media player

Now that the FM transmitter is working, we can make it do something a little more useful; in this case, we will use it to broadcast a personalized radio station with a collection of your own music.

To do this, we will write a Python script that manages to search for MP3 files and calls PiFM to broadcast them.

Calling PiFM from Python

In the PiFM download and on the PiFM website, you may have noticed that there is a Python library that can be used to control PiFM. Although, looking at the source code for it, you can see that all the library can do is call the pifm executable with the minimum number of commands, and therefore will not allow us to play MP3 files.

However, it is a simple process to create our own function that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required