Player.js
<!--
var TotalSongs, MusicName, Player, Album, SongID;
//判斷瀏覽器類型
var MSIE = navigator.userAgent.indexOf("MSIE");
//插入歌曲列表入口函數(shù)
function InsertList(SongID){
var myTo = document.getElementById("SongList");
if(!TotalSongs){
TotalSongs = myTo.options.length + 1;
document.getElementById("playlist").style.display = "none";
myTo.style.display = "block";
}else{
TotalSongs++;
}
var tStr = TotalSongs + "." + eval("M" + SongID) + "**" + eval("P" + SongID);
if(tStr.length < 20){
tStr = tStr.replace("**"," - ");
}else{
tStr = tStr.replace("**"," - ");
tStr = tStr.substr(0, 20) + "...";
}
var tO = new Option;
tO.text = tStr;
tO.value = SongID;
myTo.options[TotalSongs - 1] = tO;
}
//容錯代碼
function killerror() {return true;}
//window.onerror = killerror;
//播放歌曲
function play(){
var SongList = document.getElementById("SongList");
if(SongList.selectedIndex < 0) alert('請選擇你要播放的曲目!');
else{
SongID = SongList.options[SongList.selectedIndex].value;
var url = '';
url = eval("U" + SongID);//如果數(shù)據(jù)庫中的url字段不包含音樂的全路徑、這里要進行修改
//alert(url);
MusicName = eval("M" + SongID);
Album = eval("A" + SongID);
Player = eval("P" + SongID);
if(Player.length > 5) document.getElementById("info_person").innerHTML = Player.substr(0,5) + "...";
else document.getElementById("info_person").innerHTML = Player;
if(Album.length > 5) document.getElementById("info_collect").innerHTML = Album.substr(0,5) + "...";
else document.getElementById("info_collect").innerHTML = Album;
if(MusicName.length > 5)
{
document.getElementById("info_song").innerHTML = MusicName.substr(0,5) + "...";
}
else
{
document.getElementById("info_song").innerHTML = MusicName;
}
document.getElementById("MusicTitle").innerHTML = MusicName;
//根據(jù)不同的瀏覽器控制播放器
if(MSIE > -1){
var ExO = document.cm_Player1;
ExO.style.display = "block";
ExO.url = url;
ExO.controls.play();
showTLab();
}else{
var tB = '<embed id="cm_Player2" name="cm_Player2" type="audio/x-ms-wma" flename="mp" style="width: 300; height: 60" ';
tB += 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ';
tB += 'src="' + url + '" mastersound></embed>';
document.getElementById("cm_Player").innerHTML = tB;
setTimeout("showTLabNoIE()", 335126);
}
}
}
//控制按鈕 上一首
function Last_OneOK(){
var SongList = document.getElementById("SongList");
if((SongList.selectedIndex > 0) && (SongList.selectedIndex < TotalSongs)){
SongList.options[SongList.selectedIndex - 1].selected = true;
play();
}
}
//控制按鈕 下一首
function Next_OneOK(){
var SongList = document.getElementById("SongList");
if(SongList.selectedIndex >= 0){
if(SongList.selectedIndex < TotalSongs - 1){
SongList.options[SongList.selectedIndex + 1].selected = true;
play();
}else{
SongList.options[0].selected = true;
play();
}
}
}
function showTLab(){
if(document.cm_Player1.playState == 1) Next_OneOK();
setTimeout("showTLab()", 5000);
}
function showTLabNoIE(){
Next_OneOK();
}
-->
he__play.aspx
<%@ 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>
<!--播放器 結(jié)束-->
</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"> </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.cs
using 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("沒有參數(shù)");
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 += "http:// --></SCRIPT>" + "\n";
strjs += "<script type='text/javascript'>" + "\n";
strjs += "<!--" + "\n";
for (int i = 0; i < id.Length; i++)
{//根據(jù)傳入的歌曲id從數(shù)據(jù)庫取出歌曲名稱、歌手、歌曲地址、專輯名稱
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不認所以截掉前兩位,如果數(shù)據(jù)庫中的歌曲id比較短或者由小于2位的可以不截掉
}
strjs += "document.getElementById('SongList').options[0].selected = true;" + "\n";
strjs += "play();" + "\n";
strjs += "-->" + "\n";
strjs += "</script>";
Label1.Text = strjs;
}
}
聯(lián)系客服