Apparently this doesn't work on win2k though, and replacing the line with
  exec("CMD /C START c:\progra~1\winamp\winamp.exe \"$link\" >NUL");
I'm told doesn't seem to work.

If anyone has suggestions, I'm open

R

-----Original Message-----
From: Ross Fleming [mailto:[EMAIL PROTECTED]]
Sent: 29 April 2002 03:53
To: PHP Windows mailing list
Subject: [PHP-WIN] Running winamp thru php (was "executing an external
program")


Since giving Ranier advice on external programs, I've knocked up a simple
web-based interface for winamp that can be controlled over the internet
(useful in a networked flat where one PC is simply a music box, I can leave
apache running and remove the monitor/keyboard etc just to leave the box and
the speakers).  I'd started this project briefly a while ago (as some on the
list may remember) but gave up.  It works now, and I thought some people on
the list would appreciate a look at it.  (yes I know there are webbased
winamp controllers available, but where's the fun in that?.. ;)  )

Here's the php code for it

<<contents of index.php>>

<?
$directory = "D:/mp3s";   // Set the directory we're looking at..

if (isset($filename)) {
  $link = "d:\\mp3s\\";
  $link .= urldecode($filename);
  exec("COMMAND.COM /C START c:\progra~1\winamp\winamp.exe \"$link\" >NUL");
  header("Location:index.php?status=playing&arg=$filename");
}

if ($status=="playing") {
  $proper = urldecode($arg);
  echo "Now playing: <H3>$arg</H3>";
}

$count=0;
$handle=opendir($directory);
echo "Choose a song to play from <B>$directory</B>:<BR>";

while (false !== ($file = readdir($handle))) {
  if ($file != "." && $file != "..") {
    if (substr($file, -4)==".mp3"){
      // ignore any non-mp3 files
      $filelist[$count++] = $file;
    }
  }
}

closedir($handle);

sort ($filelist);  // alphabetize the files

for ($i=0; $i<$count; $i++) {
  $link = urlencode($filelist[$i]);
  echo "<A HREF=\"index.php?filename=$link\">$filelist[$i]</A><BR>";
}
?>

Ross


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to