Sound file plays on one computer not the other
I have some code that embeds a sound file in a website, i was just wondering why this wouldnt work on one computer but work fine on another, on one computer it plays and the other i get the message 'ERROR'
Table where the sound file is embedded
echo "<td height='298' colspan='2'>" . "<object data='sound.php?id=" . $media . "' width='391' height='298'> <embed src='sound.php' width='391' height='298'></embed>'ERROR' </object>" . "</td>";
sound.php
header('Content-type: audio/x-ms-wma');
$idd = $_GET['id'];
$query = mysql_query("SELECT * FROM media WHERE media_id= '$idd'"开发者_StackOverflow);
$row = mysql_fetch_array($query);
In fact, the problem is browser-specific. I'd recommend you to try out these four methods to play sounds in a web browser. I'm sure at least one of those works in all your tested browsers. If not, you may have forgotten to plug in your speakers.
Historical solutions
Please don't use any of these audio players anymore. They were used in the past when the first web browsers became popular and aren't really in use anymore. They don't support modern file formats like MP3, anyway.
<bgsound src="sample.wav" loop="-1">
<a href="sample.wav">Play Sample</a>
<embed src="sample.wav" autostart="false" loop="false"></embed>
<object height="50%" width="50%" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
<param name="AutoStart" value="1" />
<param name="FileName" value="sample.wav" />
</object>
Modern solution
Today, however, you would rather use a tag like <audio>
to play sound files.
<audio src="sample.ogg" controls="controls">
Your browser does not support the audio element.
</audio>
Cross-platform solution
I think you are looking for a cross-platform solution that is guaranteed to run on all web browsers. That's why you almost always end up using a Adobe Flash player solution. It's still the only plugin that is installed on nearly any computer. To take a single example, it's quite elegant to use the WordPress Audio Player. It's actually quite a small but mighty player that is easy to use. By the way, you don't need to install WordPress at all. Just download the standalone version.
精彩评论