You are not logged in.

#1 2007-02-12 01:30:47

moire
Member
Registered: 2006-01-07
Posts: 52

Scheduled mp3 playback

I'm trying to set up an icecast source client for an internet radio station. In linux, I have a variety of options, but as far as I can tell they're all simple playlist-based players. I want to be able to schedule certain sets of music to play at exact times (10pm, 11pm, etc.). The only solution I've found is an expensive commercial application for Mac OS X. I'd like to use OSS on linux, and windows is out of the question. Does anyone know of a program that can do this? It doesn't necessarily have to be an icecast source client, since I can route the output of the scheduling program into a separate source client.

If necessary, I might be willing to write my own script to do this. If I take that route, what might be a good approach?

Offline

#2 2007-02-12 01:38:58

moire
Member
Registered: 2006-01-07
Posts: 52

Re: Scheduled mp3 playback

To be more specific, here's an example of what I'd want to do:

We have three playlists:
Playlist A: .m3u with 30 minutes worth of mp3s
Playlist B: .m3u with 45 minutes worth of mp3s
Playlist X: .m3u with lots of mp3s

Playlist X plays randomly around the clock
At 10pm, we switch from X to A. A plays all the way through. When we reach the end of A, we return to X playing in random order.
At 11pm, we switch from X to B. B plays all the way through. When we reach the end of B, we return to X playing in random order.

This would involve skipping out of X in mid-track, to give priority to A and B for playing at exact times.

Last edited by moire (2007-02-12 01:40:30)

Offline

#3 2007-02-12 15:25:57

noriko
Member
From: In My Mind
Registered: 2006-06-09
Posts: 535
Website

Re: Scheduled mp3 playback

maybe something like this, just put it in /etc/cron.hourly

#!/usr/bin/env python
import os, sys
from time import strftime,time,localtime
from subprocess import Popen
hour = strftime("%H", localtime(int(time())))
clone = sys.argv[0]
player = "/usr/bin/mpg321"
plists = {'15':'playlistA.m3u','23':'playlistB.m3u','X':'playlistX.m3u'}
if hour in plists:
    plist = plists[hour]
    Popen(['/usr/bin/killall','-9',clone],shell=False)
    Popen([player,'-@',plist],shell=False).wait()
    Popen([player,'-Z@',plists['X']],shell=False).pid

Last edited by noriko (2007-02-12 15:27:42)


The.Revolution.Is.Coming - - To fight, To hunger, To Resist!

Offline

#4 2007-02-12 16:08:06

tom5760
Member
From: Philadelphia, PA, USA
Registered: 2006-02-05
Posts: 283
Website

Re: Scheduled mp3 playback

If you used mpd with icecast as a sound ouput source.  You could do something similar to what noriko suggested.  Use a cron script to fire off mpc commands to stop and load another playlist at specified times.

Offline

#5 2007-02-13 07:15:12

moire
Member
Registered: 2006-01-07
Posts: 52

Re: Scheduled mp3 playback

Cool, I didn't realize it was so simple. Thanks for the help.

Offline

#6 2007-02-13 14:23:20

Snarkout
Member
Registered: 2005-11-13
Posts: 542

Re: Scheduled mp3 playback

Also take a look at the "at" command - it's more flexible for one-time deals than cron.  It may not be needed for this particular project, but it's very handy to know about.


Unthinking respect for authority is the greatest enemy of truth.
-Albert Einstein

Offline

Board footer

Powered by FluxBB