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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.