ASP Network Programming: The method of building music server with ASP

Source: Internet
Author: User

----Music Server is a server that provides music online services, including high-end Web sites that provide portal services, Web databases, and low-end operating platforms and hardware facilities. At present, there are many such sites on the Internet and intranet, especially in some high-speed broadband LAN (such as Campus network), music server to the Internet friends to provide a good place for leisure and entertainment, but also to the site has brought a high rate of access.

----Like other sites, music servers include two sections of websites and hardware. Hardware performance and server efficiency are proportional, so how to build a website is the key to a music server. From now on, there are basically two types of websites: one is running in unix/linux environment, using PERL/C/Php/java as CGI programming language, one is running on the win NT Server platform, using asp/wincgi as the background language. The former has high efficiency, but the structure is complex, it is more suitable for large-scale site, the latter is relatively low in programming, and the ODBC driver interface makes the database connection convenient, especially suitable for music server.

----A basic music server including music online appreciation, music leaderboards, music theme search and music download four parts. The following will be the main technical aspects of how to achieve the above features.

Planning of Music Theme database

----Music Theme database is the warehouse where the Web site stores the required music data, and its planning greatly affects the structure and efficiency of the entire website. A single form can be built in the database, and multiple forms can be built as primary keys and foreign keys. In this example, for the convenience of the description, the following single-table framework is built: (Music.mdb)

Music Online Appreciation

----online appreciation means that the client uses the player to play the server-side music files. The principle is that when the client submits a music menu to the server, the server generates the corresponding. m3u file and downlink the file through the HTTP protocol to the client, and the client is fired to invoke the corresponding player to execute the file, thus realizing the music online appreciation function. Currently support for. m3u file players are Winamp, Realplayer G2, MusicMatch and so on. When these player software is installed correctly on the client, it is possible to play the. m3u file automatically. So the key to solving the problem is how to generate. m3u files in the background and downstream to the client. The following is a solution based on the FileSystem component built into ASP, and the corresponding program is given.

<%

Dim Choose,path,mydb,myset,sql,fs,mp3

' ##### get the selected song item in the List.htm form

The corresponding ID number and assigned to the string variable choose #####

Choose= "("

For I=3 to Request.form.count

Choose=choose+request.form (i) + ","

Next

Choose=left (Choose,len (choose)-1) + ")"

' ##### judge the Choose variable, if it does not contain any ID number,

Note No songs are selected in list.htm to terminate the program #####

If choose= "()" Then

Response.Redirect ("list.htm")

Response.End

End If

' ##### set the file path, you need to set the Temp directory's permissions to

Read and Write permissions for anonymous Internet users #####

Path= "E:\inetpub\wwwroot\temp\"

' ##### Create a file object #####

Set fs = CreateObject ("Scripting.FileSystemObject")

Set MP3 = fs. CreateTextFile (path+ "listen.m3u", True)

' ##### Create database object #####

Set Mydb=server.createobject ("Adodb.connection")

Mydb.open "Music"

' ##### retrieves the database and gets the song information #####

Sql= "Select Mp3name,url from" &dbname&

"Where ID in" &choose

Set Myset=tdb.execute (SQL)

Do and not myset.eof

' ##### generate an on-demand song file list #####

MP3. Write ("http +/" +myset ("url") +CHR (10))

Myset.movenext

Loop

' ##### updates the number of on-demand times in the database and

Total number of On demand #####

Sql= "Update music set click=click+1,

this=this+1 where ID in "&choose

Mydb.execute (SQL)

' ##### Cancel Object #####

Set myset=nothing

Mydb.close

Set mydb=nothing

Mp3.close

Set mp3=nothing

' ##### to download the file to the user #####

Response.Redirect ("listen.m3u")

Response.End

%>

----Note: Use this method to control the contents of the. m3u file HTTP header. IIS can be used in Winnt to set the mine content of the. m3u file type. Here's how: Start iis-> Select the Web site where the music server is located-> Click the "Properties" button-> Click on the "HTTP title" tab in the Properties tab that appears-> click the "File Type" button-> Click on the "New type" button-> ". m3u" in "corresponding extension", in the " Content type, fill in the Audio/mpegurl-> and then make sure.

Music charts

----Music Leaderboard is an indispensable content of music server, its importance is no less than the pageview of a site. It can provide instant information to the fans, guide the appreciation, and dynamically reflect the trend.

Shanghai treatment of Impotence Hospital Program I hope you can create a good music website for yourself after reading this article.

ASP Network Programming: The method of building music server with ASP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.