2

I am programming a Rasberry to Pi to become a radio player. It is meant to be used to play the local college radio in the student union hangout.

INPUT:

  • Power is turn on.

OUTPUT:

  • Audio is played through the 3,5 mm jack.

PROCESS:

  1. Device boot Raspdebian
  2. ...
  3. Start playing an ogg stream (/radiocampus_local.m3u)

How can I do this?

goldilocks
  • 86,451
  • 30
  • 200
  • 258
Eke
  • 21
  • 2

2 Answers2

3

You have to create a script in /etc/init.d, for instance "read_radio".

You have to set the proper rights on it chmod +x /etc/init.d/read_radio

You have to edit the file and create the script that will launch the radio, for instance:

#!/bin/sh
/usr/bin/mplayer -shuffle -playlist /path/to/radiocampus_local.m3u

Or whatever method you want to use to read your m3u file

Pierre-Jean
  • 2,229
  • 1
  • 15
  • 18
  • 1
    +1 for the `mplayer -playlist`, which I didn’t know and hence have written my own script to read playlists and play them with mplayer. Wasted time … – erik Mar 04 '14 at 21:04
1

There are multiple mechanism to have something start on boot-up. I don't know where the audio comes from that is specified in the .m3u file, but certainly if it is from a network, you should make sure everything the playback needs is operational.

A simple solution might be to put the command in /etc/rc.local as a background task.

The other thing you could look at is making an entry in /etc/init.d. And make a link in /etc/rc2.d (adduming 2 is the normal runlevel for a Raspberry Pi, check with runlevel), to that file. The name should be SXY... with XY a chosen number so that this is started (S) after all the dependent services are up and running.

What is less likely to work is making a @reboot entry in a crontab (assuming you have Vixie cron), not all prerequisites might be met by the time that runs.

Anthon
  • 78,313
  • 42
  • 165
  • 222