简体   繁体   中英

Play more than one song in a web page

I'm working on my HTML and Javascript project and I wanted to add music for the website..

Is there any way I can put more than one song in the code to be played? And is there anyway that the song will continue when openning the next page?

Without using Flash, you are bound to a new HTML5 technique <audio/> , which is supported in Firefox 3.5+, Safari 4+, Chrome 3+, and Opera 10+. Here is an example:

<audio src="path/to/some/audio.file" autoplay>  
  This is a fall back for old browsers, here you could implement a Flash based audio player
</audio>  

I'm not sure if it is possible to continue the song when opening the next page, maybe you could store player data in a cookie.

Here is a similar question with some good answers. The comments in that question list many duplicate questions as well. Many of those answers require HTML5. There are also various Flash-based answers as well.

If you want the song to continue when opening the next page you will need to use frames (easy) or make your website entirely AJAX-driven (more tedious).

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