简体   繁体   中英

Why cann't I display background music in my web page?

I want to display a background music in my web page, the html code is like this:

<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>test</title>
</head>
<body>
  <EMBED loop=-1 style="FILTER: blue()" width="0" height="0" src="Valder Fields.mp3" autostart="true" >  </EMBED> 

</body>
</html>

and I have put the music into the same folder of this html file, and I run it well when I test it without use web server,but when I put them into the web server and open this page again,the browser downloads the music and do not display the music,why? And what I should do if I want to display the background music when I use web server?(I use tomcat 8.0 as my web server,and I have tried other version of tomcat, they cannot work as I expect too).

somehow you can use this instead of Embed

Jsfiddle

<audio controls autoplay style="display:none;">

<source src="http://f9.stream.nixcdn.com/bd4ec51ddb6643f1b1a9703df2a5702f/54699824/NhacCuaTui877/TheHappiestTimeOfMyLife-MCMongHuhGak-3645129.mp3"  type="audio/mpeg">

</audio>

Embed the audio with HTML5.

<audio src="Valder Fields.mp3" preload="auto" controls></audio>

There are other options which you can find here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM