-1

我正在尝试将 Bohemian Rhapsody 的声音文件嵌入到我的网站中,并找到了以下代码片段:

 echo "<embed src=\"SONGURL.mp3\" autostart=\"true\" loop=\"true\" hidden=\"true\">         </embed>\n"     ."<noembed><bgsound src=\"SONGURL.mp3\" loop=\"infinite\"></noembed>"; 

我的问题是如何使它适用于我想要的歌曲?另外,我会修改其中的哪一部分?

4

1 回答 1

0

Well it seems that the HTML snippet being produced by the PHP snippet in question relies on some sort of plug-in (my guess would be Flash, but I'm not familiar with Flash at all) so it would be much more complicated than a simple edit of the HTML string. If you're willing to break backwards compatibility with old browsers, you could use the HTML5 audio tag (see for example https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_HTML5_audio_and_video).

In your case, given some filename $song_url, you could accomplish what it seems you want via string-building as

$html_snippet = "<audio src=\"$song_url\" autoplay loop></audio>";
echo $html_snippet;

To support multiple different formats (for example .ogg files for Firefox users) you can simply write

 $html_snippet = <<<EOD
 <audio autoplay loop>
     Upgrade to a newer browser!
     <source src="$song_url_mp3" type="audio/mpeg">
     <source src="$song_url_ogg" type="audio/ogg">
 </audio>
 EOD;

This HTML tag will ensure that your audio plays automatically and loops forever. To give users standard music controls, simply add a controls attribute.

于 2013-11-15T02:13:50.957 回答