SitePoint Sponsor

User Tag List

Results 1 to 23 of 23
  1. #1
    Are you ready for BSD? Marshall's Avatar
    Join Date
    Dec 2001
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool PHP WinAMP Control Module

    Folks-

    I've created a freeware native Win32 module for controlling v1.x and v2.x of Nullsoft's WinAMP Multimedia Player using the PHP programming language. It is currently beta-level software and I'm looking for willing beta testers to play with it and provide feedback. The module was compiled for PHP v4.1.1 but it may work with other 4.1.x PHP versions as well.

    The binary (php_winamp.dll) and associated documentation (README.txt) can be downloaded from http://www.magpcss.com/~marshall/php_winamp.zip. The documentation alone can be downloaded from http://www.magpcss.com/~marshall/php_winamp.README.txt.

    If anyone has questions, comments or suggestions related to this module you can contact me at the email address included with the above documentation, or, of course, post a message here :-) Thanks for the feedback, and have fun!

    - Marshall

    -------------------------------

    A sample console application (written by Sean) using this module:
    PHP Code:
    <?php
        
    If( !PHP_OS=='WIN32' ) {
            
    Define"cls""" );
        } Else {
            
    Define"cls"str_RepeatChr(10), 30 ) );
        }
        
        
    set_time_limit(0);
        Function 
    ShowMenu$level ) {
            Switch( 
    $level ) {
                Case 
    "quit":   Case "q":   Return( False ); Break;
                Case 
    "prev":   Case "z":   winamp_play_previous(); Break;
                Case 
    "play":   Case "x":   winamp_play_start(); Break;
                Case 
    "pause":  Case "c":   winamp_pause_toggle(); Break;
                Case 
    "stop":   Case "v":   winamp_stop(); Break;
                Case 
    "next":   Case "b":   winamp_play_next(); Break;
            }
            
    $text cls;
            
    $text .= "Now Playing: " winamp_play_title() . Chr(10);
            
    $text .= "WinAMP v" winamp_version() . Chr(10);
            
    $text .= "Please Select An Option:\n";
            
    $text .= "\tPrev  ('z') - Play Previous Song\n";
            
    $text .= "\tPlay  ('x') - Begin Playback\n";
            
    $text .= "\tPause ('c') - Pause Playback\n";
            
    $text .= "\tStop  ('v') - Stop Playback\n";
            
    $text .= "\tNext  ('b') - Play Next Song\n";
            
    $text .= "\t<enter> - current song\n";
            
    $text .= "'q' to quit\n>";
            echo 
    $text;
            Return( 
    True );
            Break;
        }

        
    $stdin fopen"php://stdin""r" );
        
    ShowMenu("");
        While( !
    feof$stdin ) ) {
            If( 
    winamp_running() == False ) Die( "WinAMP is not running\n" );
            
    $cmd fgets$stdin1024 );
            If( 
    strLen$cmd ) > ) {
                
    $cmd TrimstrToLower$cmd ) );
                
    $menu ShowMenu$cmd );
                If( 
    $menu == False ) Break;
            }
        }
        
    fclose$stdin );
    ?>

  2. #2
    Wanna-be Apple nut silver trophy M. Johansson's Avatar
    Join Date
    Sep 2000
    Location
    Halmstad, Sweden
    Posts
    7,400
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool... but... why?
    Mattias Johansson
    Short, Swedish, Web Developer

    Buttons and Dog Tags with your custom design:
    FatStatement.com

  3. #3
    Are you ready for BSD? Marshall's Avatar
    Join Date
    Dec 2001
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool... but... why?
    I have a WinNT computer with a great sound card and speakers sitting in the corner on a hardware keyboard/mouse/monitor switch with three other machines. This module lets me play my mp3's on that computer and control it remotely from any other computer (or palm pilot or pager or cell phone) in the house.

    There are also WinAMP plugins that let you stream mp3's over the Internet. This module could be used to create a Web-accessible interface for that service.

    And, last but not least... it was fun to write :-)

    - Marshall

  4. #4
    Wanna-be Apple nut silver trophy M. Johansson's Avatar
    Join Date
    Sep 2000
    Location
    Halmstad, Sweden
    Posts
    7,400
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Marshall
    I have a WinNT computer with a great sound card and speakers sitting in the corner on a hardware keyboard/mouse/monitor switch with three other machines. This module lets me play my mp3's on that computer and control it remotely from any other computer (or palm pilot or pager or cell phone) in the house.

    There are also WinAMP plugins that let you stream mp3's over the Internet. This module could be used to create a Web-accessible interface for that service.

    And, last but not least... it was fun to write :-)

    - Marshall
    hahaaa! Very cool idea. VERY cool. In fact, so cool, I think I'm gonna build myself one of those. I'm getting a Compaq iPaq H3870 with bluetooth soon, and combined with my Ericsson r520m, I have a constant, wireless connection to the Internet pretty much everywhere. I could turn on Barry Manilow (no pun intentended) on the way home with the girls!

    Theoretically.
    Mattias Johansson
    Short, Swedish, Web Developer

    Buttons and Dog Tags with your custom design:
    FatStatement.com

  5. #5
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    592
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re-inventing the wheel

    I also find your ideas very, very cool, and that's why I implemented them, about 1.5 years ago...

    Note: I only implemented the PHP side: a simple class to control Winamp. On the Winamp-side, there already exists a nice HTTP plug-in which you can call from the client. This plug-in is called httpQ and is available for free download on http://www.csc.uvic.ca/~karvanit/winamp/
    It's free for personal use. I did write a small C++ application for XMMS (Linux) that does the same as httpQ, but as currently only my local server has Linux, I'm not using that.

    Anyway, what I built is a little different from what you did: first I designed a PostgreSQL database that was able to store albums. This is - naturally - a 3NF normalized design, so every artist's name is stored only once, instead of with every track it's coupled with (like in those ugly MP3-tags)... The second step in my scheme involved buying a large harddisk, and storing all my albums on it. It now holds about 350 hours of music, all in high quality MP3 (about 30 GB). Finally, I built a website on top of that, and every user on the intranet can log in with his/hers own username and password.

    As for Winamp: users always have a small link in the top right corner of the browser window to the artist(s), album, and track they're currently listening to. Music can immediately be played or enqueued in Winamp (or XMMS for Linux) by simply clicking on a small icon on the website. Also, users can create their own playlists and store them in the database, and send these lists to Winamp with one click. Finally, the system keeps a list of favorite albums, artists and tracks for every user, so everyone has his/hers own personal home page on the site.

    At the moment I'm thinking about releasing my complete site to the public for free, but there are some problems, mainly in the maintenance department: I now upload new albums by hand (an ugly Perl-script, actually) and haven't yet written a nice administration program for it. As I think an application should only be released to the public when it's completely finished, this is holding me back from putting it on the web. A second task that needs to be done is implement a rating system. The database already has support for it, but the site hasn't. Finally, the database supports 'genre' and 'mood' for tracks and albums, but these aren't implemented yet on the site either. The reason is that I'm actually quite happy with what I have thus far, and are busy with all kinds of other things.

    I'm currently developing a framework for generating database administration sites, and once that's finished it shouldn't be too hard to create an administriation site for my music database. So maybe, in a month or so, I will put my stuff on the net for all to enjoy. I've been using it at home now for 1.5 years, and everybody here loves it.

    Vincent

  6. #6
    Are you ready for BSD? Marshall's Avatar
    Join Date
    Dec 2001
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    voostind writes:
    I also find your ideas very, very cool, and that's why I implemented them, about 1.5 years ago...
    Glad you like them :-)

    From what you've described your front-end design may be abstract enough to function with either httpQ or php_winamp (I'll definitely take a look at your system when you make it available). You may even find that it works faster with php_winamp then with your current httpQ interface.

    voostind writes:
    Note: I only implemented the PHP side: a simple class to control Winamp. On the Winamp-side, there already exists a nice HTTP plug-in which you can call from the client.
    The php_winamp module is simply another approach to the PHP <> WinAMP integration problem. This module provides a direct light-weight interface to the WinAMP executable via the native Win32 messaging system. Using the httpQ plug-in involves the additional overhead of initializing socket connections and negotiating the HTTP protocol -- an extra step in the communication process.

    You've got the right idea, though. Take what's available when planning your project and do whatever you like with it :-)

    - Marshall

  7. #7
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    592
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    One little problem?

    The php_winamp module is simply another approach to the PHP <> WinAMP integration problem. This module provides a direct light-weight interface to the WinAMP executable via the native Win32 messaging system. Using the httpQ plug-in involves the additional overhead of initializing socket connections and negotiating the HTTP protocol -- an extra step in the communication process.
    Yes, but doesn't your module suffer from one big problem? Your webserver has to be on the same machine as Winamp. And in my case, that's inacceptable. For one thing, I think a good webserver should run on Linux, and a good desktop machine should run on Windows. (Note: This is just my personal opinion, there's absolutely no flame intended!) Another thing is that, using httpQ, you can have as many independent listeners as you like, instead of the one Winamp on the server. But that's just my two cents...

    Vincent

  8. #8
    Are you ready for BSD? Marshall's Avatar
    Join Date
    Dec 2001
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your webserver has to be on the same machine as Winamp.
    True, you will need to have a Web server running on the machine with WinAMP. But then, in your case, httpQ is functioning as the Web server -- and if you're going to use a Web server you might as well use one that's been thoroughly stress-tested (like Apache or IIS).

    Another thing is that, using httpQ, you can have as many independent listeners as you like, instead of the one Winamp on the server.
    Shoutcast, the service & plug-in that supports multicasts of music from WinAMP, is independant of httpQ. httpQ is just one possible interface for controlling it.

    And I just noticed this new note on the httpQ Website:
    New Version, Php and winamp baby Lets you create your own web interface with winamp useing php and as well all know Php just rules.
    Might be worth looking into for anyone interested.

    - Marshall

  9. #9
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    592
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    True, you will need to have a Web server running on the machine with WinAMP. But then, in your case, httpQ is functioning as the Web server -- and if you're going to use a Web server you might as well use one that's been thoroughly stress-tested (like Apache or IIS).
    Correct, but there's a remark to be made here: Every client runs his own - very small - 'webserver', httpQ. Client computers don't want a big web server like Apache or IIS just to listen to music.

    Shoutcast, the service & plug-in that supports multicasts of music from WinAMP, is independant of httpQ. httpQ is just one possible interface for controlling it.
    Maybe I didn't make my self very clear, but I don't use streams like Shoutcast or Icecast. In my case, it looks a bit like this:

    - There's a 'big' Apache web server with a 'big' PostgreSQL database
    - There's a fileserver (Linux Samba) with all the music (MP3)
    - Users select the music they want to hear on the site, and INSTANTLY hear it, because the web server (PHP) sends the name of the files to play to the tiny httpQ plug-in on the client machine. So, on the client, it looks like it's reading 'local' files.

    The only drawback is that this only works on intranets (you need LAN access to the music). But this is not really a drawback, as sending your own high-quality music (say 256 kbps MP3) over the internet is most likely illegal. Also, streaming has two problems:
    - It isn't INSTANTENUOUS. If you enqueue a complete playlist in a stream, you don't see a list of files in Winamp, but just a single file (the stream). When I enqueue a complete album, I want to be able to skip tracks, or listen to another track twice. Or shuffle them. Or whatever.
    - It's streaming ALL THE TIME, even if there aren't listeners. This is not a big issue, but it's there.

    By the way, I did experiment with streaming (Icecast) and am thinking about something to put in my site, but having the option to instantly select files and play them still has my personal preference.

    Anyway, whatever makes your boat float, you should use. There's more ways to achieve the same goal. :-)

    Vincent

  10. #10
    Are you ready for BSD? Marshall's Avatar
    Join Date
    Dec 2001
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    - There's a 'big' Apache web server with a 'big' PostgreSQL database
    - There's a fileserver (Linux Samba) with all the music (MP3)
    - Users select the music they want to hear on the site, and INSTANTLY hear it, because the web server (PHP) sends the name of the files to play to the tiny httpQ plug-in on the client machine. So, on the client, it looks like it's reading 'local' files.
    Hmm... yes, I can see the advantages to this type of distributed instantaneous playback system. I wonder, though, if we can come up with a design independent of WinAMP-specific functionality. It would be very cool if the system could support any mp3 media player installed on the client's computer.

    The problem with most Web browsers is that they download files to a temporary directory and then send the local path to the program associated with the file's extension. This operation is what causes the delay in playback. Maybe a browser plugin or signed applet could be used to circumvent this limitation by loading the associated application directly with the remote file path instead?

    Food for thought :-)

    - Marshall

  11. #11
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    592
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    httpQ-less

    Whenever you want all your clients to be able to play files seperate from each other, you will need some kind of server-program on the client that communicates with the website. If you want to implement this yourself, you can define a protocol that does exactly what you want, and it'll probably work with UDP.

    httpQ solves the problem with a small HTTP-server. This approach is arguable, but it does work very well. The only real problem is that it only works as a Winamp plug-in. (This of course does have the advantage that clients can install it and forget about it; it'll run automatically with Winamp.)

    I 'reverse engineered' the httpQ-protocol in about 1 hour, and wrote a Perl script that works as the httpQ-server. This script runs on Linux and communicates with XMMS. In other words: making httpQ work with other programs isn't that hard. If you want my Perl script or the XMMS-remote controller (a C++ program) just let me know, and I'll post them here. The same goes for the PHP class that communicates with httpQ (or the Perl script).

    Vincent

    BTW: if you do this on an intranet, and use file sharing for your music files, your browser doesn't need to copy files to the client.

  12. #12
    Are you ready for BSD? Marshall's Avatar
    Join Date
    Dec 2001
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whenever you want all your clients to be able to play files seperate from each other, you will need some kind of server-program on the client that communicates with the website.
    Not really. Since you're using Sampa to share the files as a network FS you could get instantaneous playback simply by opening up Windows Explorer, browsing to the network drive, and double clicking the media file. The trick is passing the network address to the media player and letting it stream the file over the network instead of using the default browser functionality, which involves downloading a local copy of the file. httpQ is only one way to accomplish the former -- it listens on a network port, you send it the network path of the file, and it starts playing that file. An alternative would be to initialize the default media player using the network path as a command-line argument, the same as what happens when you double-click the file name in Windows Explorer. The second method would allow us to do without any server software (except, of course, the network FS implementation) on the client machines, and could probably be accomplished via a signed Java applet or JavaScript code (which would make it cross-browser as well as cross-media player).

    For example, you would create all of your links like:
    Code:
    <a href="foo.mp3" onClick="myApplet.load('//MyComputer/path/to/foo.mp3'); return false;">foo.mp3</a>
    Clicking this link would call the Java applet, which reads the Windows Registry entry associated with the .mp3 file extension, replaces %s (in the Registry value) with the specified network path, and executes the command-line. The command-line loads the default media player and causes it to begin playing the specified song.

    - Marshall

  13. #13
    SitePoint Addict TegSkywalker's Avatar
    Join Date
    Nov 2001
    Location
    USA
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh I love a good heated conversation

  14. #14
    Are you ready for BSD? Marshall's Avatar
    Join Date
    Dec 2001
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP WinAMP Control Module v1.1

    Folks-

    Version 1.1 of the php_winamp module is now available for download.

    http://www.magpcss.com/~marshall/php_winamp1.1.zip
    http://www.magpcss.com/~marshall/php...1.1.README.txt

    The interface is the same as v1.0 but the functions now do validity testing on parameters. If you pass an invalid parameter value -- for instance, a value of 5 when the function is expecting a boolean -- it will throw a Warning message.

  15. #15
    Are you ready for BSD? Marshall's Avatar
    Join Date
    Dec 2001
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    v1.1 of the php_winamp module has moved to http://pcs.magpcss.com/files/php_winamp1.1.zip.

    - Marshall

  16. #16
    ********* Celica Lover Coomer's Avatar
    Join Date
    Apr 2002
    Location
    Not worth the drive
    Posts
    474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow! This is my first time seeing this and it sounds pretty cool. I think I'll download it tomorrow and try it out.
    + Celica =
    6G Celicas :: My '94-99 Toyota Celica resource

  17. #17
    SitePoint Addict
    Join Date
    Feb 2002
    Location
    Atlanta, GA
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You guys amaze me.

    I am a nat amidst giants...


  18. #18
    SitePoint Enthusiast Cabbage's Avatar
    Join Date
    Jun 2001
    Location
    New Jersey
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    >>all in high quality MP3
    that made me laugh
    high quality is shn, wav, aiff
    ~Cabbage
    http://www.jimmieschickenshack.net
    want to trade live recordings? JCS, Smashing Pumpkins, Local H, Toadies

  19. #19
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Cabbage
    >>all in high quality MP3
    that made me laugh
    high quality is shn, wav, aiff
    How are mp3's not high in quality? Just grab yourself a 256 kbps version and you're set.

    -Colin
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  20. #20
    SitePoint Zealot ant1832's Avatar
    Join Date
    Apr 2002
    Location
    Tucson, AZ
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Cabbage
    >>all in high quality MP3
    that made me laugh
    high quality is shn, wav, aiff
    I think he meant high quality compared to some 128 kbps rips that some people have.

  21. #21
    SitePoint Enthusiast Cabbage's Avatar
    Join Date
    Jun 2001
    Location
    New Jersey
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nah I meant mp3's in general...i just wanted to see if someone would take the bait and they did. www.etree.org
    ~Cabbage
    http://www.jimmieschickenshack.net
    want to trade live recordings? JCS, Smashing Pumpkins, Local H, Toadies

  22. #22
    SitePoint Member
    Join Date
    May 2002
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yum yum...

    this is a nice module. although theres better ways of doing this

    .icecube

  23. #23
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Grand Rapids, MI
    Posts
    1,284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Aes
    How are mp3's not high in quality? Just grab yourself a 256 kbps version and you're set.

    -Colin
    Well, or you could get the almighty DFX. Its great. A must have. It enhances the sound coming from the speakers. The difference is noticable. You can get it from here.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •