Traditional Culture Encyclopedia - Traditional stories - How to play songs continuously online on static (html) web pages?

How to play songs continuously online on static (html) web pages?

I have done Flash player and JS has not, but I think the principle should be the same. According to you, you should use JS to monitor the player plug-in in the webpage.

Say it briefly.

Materials: songs, song file list (it can be XML, anything else, any file), and several simple JS statements.

Handling:

1. When generating a webpage, name the ID of the music player plug-in as WMA. Of course, you can name it at will, but it's easy to explain here.

2. Read the content in XML format.

At the same time, the corresponding song names and addresses in XM are stored in the array testmp3 (this array is of course a two-dimensional array, and the data groups are song names and song addresses respectively).

Ok, here, the preparations are done, and here is the key point-continuous broadcast.

3. Relevant statements:

First, define the function getWMAtime.

Second, use interval = setinterval ("getWMAtime ()", 900), which means calling the function getwmatime every 900 milliseconds and putting it into the interval.

If you want to use "previous song" and "next song", you can use them as functions.

Assign the music address to WMA. URL, and use wma.controls.play (); Play, with wma.controls.stop (); Stop playing and use wma.controls.pause (); Pause playback. After changing the music address, remember to load the new lyrics with Ajax!

Another one:

The content of the getWMAtime function is to read the playing time of the current lyrics.

Current playing time: wma.controls.currentposition;

Total song duration: wma.currentmedia.duration;

After reading the current time, compared with the time items in the array, the result is the same (for other reasons, different situations may occur, so use ">; =")

If the previous playing time = the total time of the song, change WMA. Use JS for the URL attribute, and then use wma.controls.play (); The address of.

Ok, a simple JS player is finished.

If you don't understand, you can visit my blog I hope I can discuss it with you.