You are not logged in.
I'm looking for a bash script (or anything that will get the job done) that will:
-stream music from my favorite internet radio station (ie: di.fm)
-play stream for a given time in increments of 1hr (ie: 1 hr, 3 hrs, etc)
-at the end of the given time, fade out the music then terminate stream after fade out is complete.
-terminate script (or application that is performing these tasks)
Ideally, the script will take in the internet radio station and time as arguments. I have Rhythmbox which I currently use to stream. I don't care if the script opens applications for use in this process. Can anyone help me with this? Or at least get me pointed in the right direction?
PS: I plan on using this as my music to listen to while I'm trying to go to sleep, hence the time limit and fade out. If the music stopped abruptly I would most likely wake up.
Thanks guys.
Offline
I know in mplayer, you can do most of that.
For example, running this from console will play Lounging Sound radio for exactly one hour;
mplayer -endpos 01:00:00 http://67.159.44.146:8002/
I'm not sure about the fade out effect, you might have to Google for that information. I'd recommend the 'mplayer-svn-nogui' package in AUR (or check out the one here) if you decide to go this route.
Oh, you might want to check out MPD too... it could possibly do something like this.
Last edited by Pnevma (2008-07-22 12:56:30)
Offline
MPD can't play from streams. I second mplayer
[git] | [AURpkgs] | [arch-games]
Offline
Geez, I would have suggested something along the lines of
$ mplayer; sleep 20m && killall mplayer
i should probably look at options for the more robust applications from now on.
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
MPD can't play from streams. I second mplayer
I'm pretty sure it can, I used to play streams all the time with MPD + Sonata.
Offline
Sonata can play streams. MPD cannot.
[git] | [AURpkgs] | [arch-games]
Offline
I've been thinking about this a while. I was messing with Sox and mplayer for a while but I think this is the simplest method.
Save this as sleep_stream.sh and chmod +x on it.
#!/bin/bash
# ./sleep_stream.sh <stream> <time_in_minutes>
time=$2m
mpc clear
ext=${1##*.}
case "$ext" in
"m3u" )
cat $1 | mpc add
mpc play
;;
"pls" )
grep '^File[0-9]*' $1 | sed -e 's/^File[0-9]*=//' | mpc add
mpc play
;;
* )
echo $1 | mpc add
mpc play
;;
esac
sleep $time
while [ "`mpc | sed -n '/^volume/ { s/^volume:\s\([0-9]*\).*/\1/p }'`" -gt 0 ]; do
mpc volume -1 > /dev/null
sleep 1
done
The script will not sanitise the input but this works beautifully.
Offline
You know for the filetype checking that you can just
case $1 in
*.m3u) do_playlist ;;
*.mp3) do_mp3 ;;
*) do_default ;;
esac
No need to mess with bash string functions.
[git] | [AURpkgs] | [arch-games]
Offline
You know for the filetype checking that you can just
case $1 in *.m3u) do_playlist ;; *.mp3) do_mp3 ;; *) do_default ;; esac
No need to mess with bash string functions.
I didn't know but it's not a show stopper for me. The most important part was deciding how to play a stream _and_ fadeout after a set amount of time.
Offline