Jump to content

[SOLVED] How to play a Wav file using php


suma237

Recommended Posts

Can you please check this code

 


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<title>Untitled Document</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<SCRIPT TYPE="text/javascript">
<!--
function soundplay()
{
alert("fff");
if (navigator.appName == "Netscape")
   {
   document.MySound.play(false)
   return false;
   }
else
   return true;
}
//-->
</SCRIPT>
</head> 
<body> 
   
      <?

       $music=$_GET['music'];

            $dir ="song";

       
  
            $dh = opendir($dir);

       
  
            while ( !(($file = readdir($dh)) === false) )

            {
   
       

                if ($file == "." || $file == "..") continue;

       

                if (eregi(".wav",$file))

                    {

  
       
echo' <a href="?music=true&file='. $dir . '/' . $file  . '" onClick="return soundplay()">'.$file.'</A>';
                       

       

                }

            }

            if($music == 'true')
        {

                               $file = $_GET['file'];


                  echo '<EMBED  src="'. $dir . '/' . $file . '"  NAME="MySound"  HEIGHT=144 WIDTH=166 MASTERSOUND HIDDEN >';

              }

       
  
      ?>
</body> 
</html> 
  




 

Inside the loop it is not working.Why?

PHP can not play WAV files..

 

you would be better off using Flash or javascript to play them.

 

as for the code supplied it will only work on Netscape, see the javascript section for more info..

 

as for "Inside the loop it is not working.Why?"

 

its working exactly how its been programmed to work..

 

please read How To Ask Questions The Smart Way

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.