View previous topic :: View next topic |
Author |
Message |
Anonymous Guest
|
Posted: Wed Jan 17, 2007 11:24 pm Post subject: Icecast + IceS 0.4 rock! This is what I did. |
|
|
Hi,
I installed icecast + ices 0.4 today to stream mp3's mainly for my personal use as I travel around with my laptop and wanted to be able to listen to my music collection wherever I go
After a few hours of coding, I now have a system (combination of pure php and a few linux shell scripts, no mysql or anything - I also had to learn a bit perl to modify the original perl script to suit my purposes) to show current track, track history, next track + a neat wishlist/queue of (I set the current maximum to 10) songs so that I can kinda change songs over web. Showing my system out is pretty pointless for most of you, because I did it for myself and therefore it is in Finnish. You can ask for URL, but I don't promise to visit this forum often
Just then I found out some people were having trouble with exactly the things I solved today. So I decided to share a bit of my solution here:
1) a shell script
Code: |
find /home/username/mp3/ -name '*.mp3' -print > /home/username/public_html/whatever/all_songs.txt |
2) ices.conf (the important part)
Code: |
<!-- One of builtin, perl, or python. -->
<Type>perl</Type>
<!-- Module name to pass to the playlist handler if using perl or python.
If you use the builtin playlist handler then this is ignored -->
<Module>ices</Module> |
3) /usr/local/etc/modules/ices.pm (the important part)
Code: |
sub ices_get_next {
print "Perl subsystem quering for new track:\n";
$domyphp = `php /home/username/mp3/getsong.php`;
return $domyphp;
} |
4) getsong.php
Code: |
<?php
function makeWish () {
$allsongs = file("/home/username/public_html/whatever/all_songs.txt");
srand((float) microtime() * 10000000);
$filename = trim($allsongs[array_rand($allsongs)]);
$history = file("/home/username/whatever/logs/ices.log");
$tracks = array();
foreach ($history as $row) {
if (substr($row,0,7)=="Playing") {
$tracks[] = substr($row,strrpos($row,"/")+1);
}
}
$tracks = array_slice(array_reverse($tracks),0,30);
$filecheck = substr($filename,strrpos($filename,"/")+1);
while (in_array($filecheck,$tracks)===true) {
srand((float) microtime() * 10000000);
$filename = trim($allsongs[array_rand($allsongs)]);
$filecheck = substr($filename,strrpos($filename,"/")+1);
}
return $filename;
}
$wishes = file("/home/username/public_html/whatever/wishes.txt");
if (count($wishes)==0) {
$filename = makeWish();
} else {
$filename = trim(array_shift($wishes));
$file = fopen("/home/username/public_html/whatever/wishes.txt","w");
if (count($wishes)>0) {
foreach ($wishes as $song) {
fwrite($file,trim($song)."\n");
}
} else {
$newWish = makeWish();
fwrite($file,$newWish."\n");
}
fclose($file);
}
echo "$filename"; ?> |
Part 4 also featured the code needed to get the track history from log file. I am sorry that this still is NOT for beginners - you most likely need to know quite a bit about (at least) php to be able to do anything neat with this. I hope you the best luck if you are about to try this out
The main point of my post was to say that Icecast + IceS rocked my world. I know I may have done some things a bit overcomplicated here, but at least it works the way I wanted it to work
Greets,
TrashF
EDIT: Whoops, forgot to change one variable name in translation.
Last edited by Anonymous on Mon Feb 12, 2007 9:50 am; edited 1 time in total |
|
Back to top |
|
 |
Anonymous Guest
|
Posted: Mon Feb 12, 2007 9:41 am Post subject: |
|
|
If someone wants to check it out, go to http://radio.taistelumarsu.org/
It's not for public use so it's a bit ugly and so, but hope everyone interested gets some kind of an image. |
|
Back to top |
|
 |
liteFun
Joined: 13 Jan 2006 Posts: 79
|
Posted: Thu Apr 19, 2007 10:45 am Post subject: |
|
|
Looks to do it's job
How did you do that progressbar?  |
|
Back to top |
|
 |
Anonymous Guest
|
Posted: Sat Jun 16, 2007 12:48 pm Post subject: |
|
|
liteFun wrote: |
Looks to do it's job
How did you do that progressbar?  |
The page has a javascript that calls a simple PHP script every second to get the % of how much of the song is played (progress info can be found from /logs/ices.cue). This also makes it possible to refresh page every time the song changes
Sorry for the delayed reply, I don't visit this forum so often... |
|
Back to top |
|
 |
Anonymous Guest
|
Posted: Wed Aug 29, 2007 4:04 pm Post subject: long filenames |
|
|
Hi there,
I have a Question regarding your scripts, when i run ices it cannot find the files specified. Tho when i dont use the script, and use the builtin-option it can find the files (using same playlist)
I think its because i have alot of special characters in my file-location, like & = - etc.
I tryd modifying the PHP script with escshellarg, addslashes etc but non worked. You have any idea how to solve this?
Thanks |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group subRebel style by ktauber
|