当前位置: 代码迷 >> J# >> 怎样连续播放音乐,该如何解决
  详细解决方案

怎样连续播放音乐,该如何解决

热度:9012   发布时间:2013-02-25 00:00:00.0
怎样连续播放音乐
在.net中怎样连续播放自己收藏的音乐文件

------解决方案--------------------------------------------------------
Player.js

C# code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="he__play.aspx.cs" Inherits="search_he__play" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head>      <title>音乐连播</title></head><body>      <form id="form1" runat="server"><div align="center"><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><table id="__01" width="769" height="521" border="0" cellpadding="0" cellspacing="0" class="play_bg01"><tr>    <td>     <img src="images/musicplay_01.gif" width="769" height="12" alt=""></td></tr><tr>    <td><table id="Table1" width="769" height="494" border="0" cellpadding="0" cellspacing="0">            <tr>              <td class="play01" height="31" style="font-size:12px">歌曲全名:<span id="MusicTitle">sssssss</span></td>            </tr>            <tr>              <td valign="top"><table id="Table2" width="769" height="465" border="0" cellpadding="0" cellspacing="0">                <tr>                  <td height="10" colspan="2" align="left" valign="top"><img src="images/musicplay_02_02_01.gif" width="769" height="10" alt=""></td>                </tr>                <tr>                  <td width="329" height="445" align="left" valign="top"><table id="Table3" bgcolor="#FFFFFF" style="margin-left:25px; font-size:12px; padding:1px;" width="301" height="209" border="0" cellpadding="0" cellspacing="0">                    <tr>                      <td>歌手:<span id="info_person">sssssss</span> 专辑:<span id="info_collect">sssssss</span> 歌曲:<span id="info_song">sssssss</span></td>                    </tr>                    <tr>    <td height="60" align="center" id="cm_Player"><!--播放器 开始--><object id="cm_Player1" name="cm_Player1" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"type="application/x-oleobject" style="width: 300; height: 60; display: none"><param name="url" value=""><param name="rate" value="1"><param name="balance" value="0"><param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="1"><param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1"><param name="baseURL" value><param name="volume" value="84"><param name="mute" value="0"><param name="uiMode" value="full"><param name="stretchToFit" value="-1"><param name="windowlessVideo" value="0"><param name="enabled" value="-1"><param name="enableContextMenu" value="-1"><param name="fullScreen" value="0"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value><param name="enableErrorDialogs" value="0"></object><!--播放器 结束-->    </td>                    </tr>                    <tr>                      <td>     <div id="playlist">正在导入歌曲播放列表,2至10秒中完成,请您稍等片刻.....</div>     <select id="SongList" size="5" style="width:300px; background:#52b7d6; color:#ffffff; border: 1px solid #333333; display: none" OnDblClick="play()"></select>       </td>                    </tr>                    <tr>                      <td><img src="images/song_up.gif" width="79" height="20" onclick="Last_OneOK()"> <img src="images/song_down.gif" width="79" height="20" onclick="Next_OneOK()"></td>                    </tr>                  </table></td>                  <td width="440" align="left" valign="top">&nbsp;</td>                </tr>                <tr>                  <td colspan="2"><img src="images/musicplay_02_02_03.gif" width="769" height="10" alt=""></td>                </tr>              </table></td>            </tr>          </table>              </td></tr><tr>    <td>     <img src="images/musicplay_03.gif" width="769" height="15" alt=""></td></tr></table><asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></body></div>      </form></body></html>he__play.aspx.csusing System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partial class search_he__play : System.Web.UI.Page{      protected void Page_Load(object sender, EventArgs e)      {          if (Request.QueryString["QUERY_STRING"] == null)          {              PopPrompt.pop("没有参数");              return;          }          string ListStr;          ListStr = Request.QueryString["QUERY_STRING"].ToString();          string[] id = ListStr.Split(',');          string strjs="";          string u1 = "";          string m1 = "";          string p1 = "";          string a1 = "";          strjs += "<script language='javascript' src='Player.js'></script>" + "\n";          strjs += "<SCRIPT LANGUAGE=JAVASCRIPT><!-- " + "\n";          strjs += "if (top.location != self.location)top.location='http://localhost/';" + "\n";          strjs += "// --></SCRIPT>" + "\n";          strjs += "<script type='text/javascript'>" + "\n";          strjs += "<!--" + "\n";          for (int i = 0; i < id.Length; i++)          {//根据传入的歌曲id从数据库取出歌曲名称、歌手、歌曲地址、专辑名称              u1 = DbHelperSQL.GetSingle("select url from tbl_music where musicid=" + id[i].ToString()).ToString();              m1 = DbHelperSQL.GetSingle("select musicname from tbl_music where musicid=" + id[i].ToString()).ToString();              p1 = DbHelperSQL.GetSingle("select singername from tbl_singer where singerid=(select singerid from    tbl_music where musicid=" + id[i].ToString() + ")").ToString();              a1 = DbHelperSQL.GetSingle("select albumname from tbl_album where albumid=(select albumid from    tbl_music where musicid=" + id[i].ToString() + ")").ToString();              strjs += "var U" + id[i].Remove(0,2) + " = '" + u1 + "';" + "\n";              strjs += "var M" + id[i].Remove(0, 2) + " = '" + m1 + "';" + "\n";              strjs += "var P" + id[i].Remove(0, 2) + " = '" + p1 + "';" + "\n";              strjs += "var A" + id[i].Remove(0, 2) + " = '" + a1 + "';" + "\n";              strjs += "InsertList(" + id[i].Remove(0, 2) + ");" + "\n";//由于歌曲id太长js不认所以截掉前两位,如果数据库中的歌曲id比较短或者由小于2位的可以不截掉          }          strjs += "document.getElementById('SongList').options[0].selected = true;" + "\n";          strjs += "play();" + "\n";          strjs += "-->" + "\n";          strjs += "</script>";          Label1.Text = strjs;      }}
  相关解决方案