Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Icecast + IceS 0.4 rock! This is what I did.

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> F.A.Q.
View previous topic :: View next topic  
Author Message
Anonymous
Guest





PostPosted: Wed Jan 17, 2007 11:24 pm    Post subject: Icecast + IceS 0.4 rock! This is what I did. Reply with quote

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 Smile

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 Embarassed

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 Smile

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 Very Happy

Greets,
TrashF Twisted Evil

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





PostPosted: Mon Feb 12, 2007 9:41 am    Post subject: Reply with quote

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

PostPosted: Thu Apr 19, 2007 10:45 am    Post subject: Reply with quote

Looks to do it's job Wink
How did you do that progressbar? Surprised
Back to top
View user's profile Send private message
Anonymous
Guest





PostPosted: Sat Jun 16, 2007 12:48 pm    Post subject: Reply with quote

liteFun wrote:
Looks to do it's job Wink
How did you do that progressbar? Surprised


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 Smile

Sorry for the delayed reply, I don't visit this forum so often...
Back to top
Anonymous
Guest





PostPosted: Wed Aug 29, 2007 4:04 pm    Post subject: long filenames Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> F.A.Q. All times are GMT
Page 1 of 1

 
Jump to:  
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