文件1:list.asp,音乐文件列表
<%for i=1 to 5 rsponse.write "<form method=post action='play.asp'>" response.write "<input type=checkbox value="&i&" name=Music_ID>" //value值为记录对应id,此处用变量i代替 response.write "音乐"&i //此处为音乐名称 next response.write "<input type=submit name=submit>" %>
文件2:Play.asp 调用media组件并实现播放
<% Music_ID=request.form("Music_ID") //获取list.asp传递变量music_ID %> <object id="MediaPlayer1" style="Z-INDEX: 2; LEFT: 18px; VISIBILITY: visible; POSITION: absolute; TOP: 40px" codeBase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701standby=Loading" type="application/x-oleobject" height="0" width="0" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" VIEWASTEXT> <param NAME="URL" VALUE="play_list.asp?Music_ID=<%=Music_ID%>"> <param NAME="rate" VALUE="1"> <param NAME="balance" VALUE="0"> <param NAME="currentPosition" VALUE="0"> <param NAME="defaultFrame" VALUE> <param NAME="playCount" VALUE="100"> <param NAME="autoStart" VALUE="-1"> <param NAME="currentMarker" VALUE="0"> <param NAME="invokeURLs" VALUE="-1"> <param NAME="baseURL" VALUE> <param NAME="volume" VALUE="100"> <param NAME="mute" VALUE="0"> <param NAME="uiMode" VALUE="none"> <param NAME="stretchToFit" VALUE="0"> <param NAME="windowlessVideo" VALUE="0"> <param NAME="enabled" VALUE="-1"> <param NAME="enableContextMenu" VALUE="0"> <param NAME="fullScreen" VALUE="0"> <param NAME="SAMIStyle" VALUE> <param NAME="SAMILang" VALUE> <param NAME="SAMIFilename" VALUE> <param NAME="captioningID" VALUE> </object>
文件3:play_List.asp,实现连续播放文件列表
数据库music_List 字段Music_ID,Music_Name,Music_Url,Singer
sql="select * from Music_List where Music_ID in ("&Request.QueryString("Music_ID")&")" //获取Play.asp传递的变量music_ID并进行查询 set rs=conn.execute(sql) if rs.eof and rs.bof then response.write "<ASX version = ""3.0"">" response.write "<TITLE>F369.NET-播放器</TITLE><author>音乐听吧</author>" response.write "<abstract>Music.F369.Net</abstract><copyright>在线试听</copyright>" do while not rs.eof response.write "<entry SKIPIFREF=""YES"">" response.write "<title>"&rs("Music_Name")&"</title><author>"&rs("Music_ID")&"</author>" response.write "<copyright>"&rs("Music_ID")&"</copyright>" response.write "<ref href="""&rs("Music_Url")&"""/>" response.write "<param name=""Artist"" value="""&rs("Singer")&"""/>" response.write "<param name=""Album"" value=""http://www.f369.net";"/>" response.write "<param name=""Title"" value="""&rs("Music_Name")&"""/>" response.write "</ENTRY>" rs.movenext loop response.write "</ASX>" rs.close set rs=nothing PS:实战中大家要注意sql的查询语句最好用in,因为这样可以滤掉重复的ID 当然大家也可以写个函数请除掉重复的值,还要注意检测id的空值和非法字符。 |