SoFunction
Updated on 2025-04-11

Multiple songs continuously played asx playlist file

I often see some music sites having this function: select the check box before the song name on the page at will, and click the play button to achieve continuous playback of these selected songs.

If a single audio file is played in a document, use a common method, which is similar to the third method described here.

But now there are many songs, and the method is not the same. I remember the list file m3u saved when using Winamp player, the current MediaPlayer player uses the wpl list file format. Of course, what I want to use here is the asx playlist file

ASX file is a text file. Its main purpose is to redirect stream information, similar to RPM (RM's transit file) file.

The main reason for using ASX files to redirect stream information is that currently common browsers usually cannot directly support the protocol MMS used to play stream information, so we use ASX files.

ASX contains the URL corresponding to the media content. When we contact ASX in HTML, the browser will directly send the ASX content to MEDIA PLAYER. MEDIA PLAYER will use the corresponding protocol to open the multimedia information flow or multimedia file in the specified location based on the information of the ASX file.

After using ASX files, when the browser finds that a connection is related to ASX, it knows that it needs to use MEDIA PLAYER to play stream information, so it will start MEIDA PLAYER, and MEDIA PLAYER can use the MMS protocol to play stream information.


A standard ASX file format is as follows:


<ASX Version = "3.0">
<Entry> <Ref href = "http://server/" /> </Entry>
<Entry> <Ref href = "http://server/" /> </Entry>    
<Entry> <Ref href = "http://server/" /> </Entry>
</ASX>

 


Note that the ASX file itself is not the media file itself, but the list of media files. The address of the media file is represented by the href attribute of the child node Ref of the Entry node.

Of course, you can also define more child nodes in the Entry node to enrich the information of the current media file, such as:



<ASX Version = "3.0">

<Entry> 
<Ref href = "/edit/uploadfile/200583195159842.MP3" />
<Title>Lonely ()</Title>
<Author>[Nana]()</Author>
<Copyright>As the right holder of the record company or singer</Copyright>
</Entry>

<Entry>
<Ref href = "/mov/mymp3/yeyeye.mp3" />
<Title>yeyeye ()</Title>
<Author>[DJ]()</Author>
<Copyright>Affiliate the record company or singer's right holder</Copyright>
</Entry>

</ASX>

 


Where <title></title> represents the title of the media file, <Author></Author> represents the author of the media file (i.e. the artist who sang the song), and <Copyright></Copyright> represents the copyright notice of the media file.

For more details, please refer to: /kb/247355/zh-cn

With an understanding of the ASX file format, you can create media playlist files by yourself to meet the requirements of continuous playback of multiple songs.

So how do you insert ASX files into the page for playback? The usual method is to insert the asx file into the page as a normal media file (as mentioned in the common method mentioned at the beginning of this article)

However, for dynamic song playback, different list files are required for each song selection, which is obviously not suitable, so ASX content must be generated dynamically.

Because the file format of ASX is fixed, you can query the relevant media file path according to the different songs selected by the user and write out the ASX file contents in a loop. So, while keeping the ASX file format unchanged, the asx file suffix name can be modified to .asp for reference

For example: http:///2006/testmusic/
The connected media playlist file is: http:///2006/testmusic/
Although the media list file is of Asp type, its content is in Asx format, which does not affect the playback of the song.

In addition, <% ="video/x-ms-asf" %> is the method of ASP declaring the current file as an asx file, but when the file is applied on the first line, the user opens the file link and will automatically use the local MediaPlayer call to play.

Test: http:///2006/testmusic/

OK, let’s talk about static content first. The next step is to dynamically generate the content of the media list file through database extraction, to be continued.