[code=javascript]
var _total = 7;
var _pageIndex = 1;
var _pageSize = 7;
function initList() {
if (_ids.length > 0) {
initPlayList()
} else {
getPlaylist(sing.cookie)
}
initHtml();
wsplayer.setPlayList(_list, 0);
deleteCookie("lb", "/", ".xxxxx.com")
}
function pageHtml(p) {
var a = Math.ceil(_total / _pageSize);
var b = "";
if (p > 0) {
if (_pageIndex < a) {
_pageIndex++;
b = "<p class=\"l_page\" style=\"left:0px;\"><span>" + _pageIndex + "/" + a + "</span>";
if (_pageIndex < a) {
b += "<a href=\"###\" class=\"next\" οnclick=\"pageHtml(1)\">下一页</a>"
} else {
b += "<a href=\"###\" class=\"no_next\">下一页</a>"
}
b += "<a href=\"###\" class=\"previous\" οnclick=\"pageHtml(0)\">上一页</a>";
b += "</p>";
pageList(_pageIndex, b)
}
} else {
if (_pageIndex > 1) {
_pageIndex--;
b = "<p class=\"l_page\"><span>" + _pageIndex + "/" + a + "</span>";
b += "<a href=\"###\" class=\"next\" οnclick=\"pageHtml(1)\">下一页</a>";
if (_pageIndex > 1) {
b += "<a href=\"###\" class=\"previous\" οnclick=\"pageHtml(0)\">上一页</a>"
} else {
b += "<a href=\"###\" class=\"no_previous\">上一页</a>"
}
b += "</p>";
pageList(_pageIndex, b)
}
}
}
function pageList(p, b) {
var c = 70;
_$.ajax({
async: false,
type: "post",
url: "m.ashx?rand=" + Math.random(),
data: "cmd=" + c + "&pageindex=" + _pageIndex,
dataType: "json",
success: function(o) {
if (o.status == 1) {
_total = o.total;
var a = "";
for (var i = 0; i < o.datas.length; i++) {
a += "<a href=\"?channelid=" + o.datas[i].channelID + "\"><span class=\"item_img\">";
a += "<img src=\"" + o.datas[i].logo + "\" width=\"80\" height=\"70\" />";
if (i == 0) {
a += "<img class=\"new\" src=\"images/new.png\" width=\"34\" height=\"34\" />"
}
a += "</span><h3>" + o.datas[i].name + "</h3><p>" + o.datas[i].memo + "</p></a>"
}
a = "<h2>往期歌单</h2>" + a + b;
_$("#ScrollContent").html(a)
}
}
})
}
function readPlayer() {
wsplayer = new $wsp.mediaElement("#playerbox", {
loopMode: 1,
playIndexChanged: function(a, b) {
getPlayInfo(a, b)
},
stats: {
enable: true,
source: 4
},
errorToPlay: function(a) {
if (a.playList.length > 1) {
if (a.playIndex < a.playList.length - 1) {
a.play(a.playIndex + 1)
} else {
a.play(0)
}
}
},
unsupport: function(a) {
if (a.playList.length > 1) {
if (a.playIndex < a.playList.length - 1) {
a.play(a.playIndex + 1)
} else {
a.play(0)
}
}
},
customInit: function(a, b) {
_$(".repeat").click(function() {
if (wsplayer.loopMode) {
if (!_$(this).hasClass("repeat-off")) {
_$(this).attr("value", "顺序播放").attr("title", "顺序播放");
_$(this).addClass("repeat-off")
}
} else {
_$(this).attr("value", "单曲循环").attr("title", "单曲循环");
_$(this).removeClass("repeat-off")
}
a.setLoopMode()
})
}
})
}
function selectIndex() {
if (isCurrentList()) {
_$("#list_ScrollContent div:eq(" + sing.playIndex + ")").addClass("selected")
}
}
function initCss() {
_$(".jp-share").hover(function() {
_$(this).find("span").fadeIn()
},
function() {
_$(this).find("span").hide()
});
_$(".item").hover(function() {
_$(this).find("span.action_shop").show().find("a.del").show()
},
function() {
_$(this).find("span.action_shop").hide()
});
_$(".share").hover(function() {
_$(this).find("span").fadeIn()
},
function() {
_$(this).find("span").hide()
})
}
function getPlayInfo(a, b) {
sing.playIndex = a;
if (sing.playIndex >= 0) {
_$("#list_ScrollContent div").removeClass("selected");
selectIndex();
document.title = b.songname + " - 音乐";
var c = b.songname;
if (c.len() > 44) {
c = c.sub(44)
}
_$(".sing_title").html("<a href=\"http://" + b.songtype + ".xxxxx.com/" + b.songid + ".html\" target=\"_blank\">" + c + "</a>");
_$(".sing_remark").html("歌手:<span>" + b.song + "</span>人气:<span>" + b.hit + "</span>");
getSongInfo(b.songid, b.songtype)
}
}
function getPlaylistHtml() {
var b = "";
if (_list.length == 0) {
b = "<div style=\" text-align:center; font-size:16px; margin:120px auto 0;\">播放列表为空,<a href=\"/m/?abc=11\" style=\" color:#6DB823\">随便听听</a>!</div>";
_$("#list_ScrollBox").append(b)
} else {
for (var i = 0; i < _list.length; i++) {
if (i % 2 == 1) {
b += "<div class=\"item jg\">"
} else {
b += "<div class=\"item\">"
}
b += "<p class=\"item_con\" οnclick=\"playsong(this)\" songid=" + _list[i].songid + " songname=\"" + _list[i].songname + "\" songtype='" + _list[i].songtype + "' hit=" + _list[i].hit + " url=\"" + _list[i].mp3 + "\" song=\"" + _list[i].song + "\">";
b += "<span class=\"index\">" + (i + 1) + "</span>";
var c = _list[i].songname,
_song = _list[i].song;
if (c.len() > 28) {
c = c.sub(28)
}
if (_song.len() > 14) {
_song = _song.sub(14)
}
b += "<span class=\"title\"><a href=\"javascript:;\" title=\"\">" + c + "</a></span>";
b += "<span class=\"name\">" + _song + "</span><span class=\"rq\">" + _list[i].hit + "</span></p>";
b += "<span class=\"action_shop\"><a href=\"javascript:;\" οnclick=\"like(" + _list[i].songid + ",'" + _list[i].songtype + "')\" title=\"喜欢\" class=\"like\">1</a>";
b += "<a href=\"http://" + _list[i].songtype + ".xxxxx.com/Down.aspx?sid=" + _list[i].songid + "\" target=\"_blank\" title=\"下载\" class=\"download\">1</a>";
b += "<a href=\"javascript:;\" title=\"\" class=\"share\">";
b += "<span class=\"weibo_btn\" mp3=" + _list[i].mp3 + ">";
b += "<input type=\"button\" class=\"qzone\" οnclick=\"share(this,1)\" shareID=1 title=\"QQ空间\"/>";
b += "<input type=\"button\" class=\"sina\" οnclick=\"share(this,1)\" shareID=2 title=\"新浪微博\"/>";
b += "<input type=\"button\" class=\"tencent\" οnclick=\"share(this,1)\" shareID=3 title=\"腾讯微博\"/>";
b += "<input type=\"button\" class=\"tieb\" οnclick=\"share(this,1)\" shareID=4 title=\"百度贴吧\"/>";
b += "<input type=\"button\" class=\"renren\" οnclick=\"share(this,1)\" shareID=5 title=\"人人网\"/>";
b += "<input type=\"button\" class=\"kaix\" οnclick=\"share(this,1)\" shareID=6 title=\"开心\"/>";
b += "<input type=\"button\" class=\"xiaoy\" οnclick=\"share(this,1)\" shareID=7 title=\"校友\"/>";
b += "<input type=\"button\" class=\"doub\" οnclick=\"share(this,1)\" shareID=8 title=\"豆瓣\"/>";
b += "</span><span class=\"str\"></span>";
b += "</a>";
if (_list[i].listindex == 0) {
b += "<a href=\"javascript:;\" οnclick=\"delFromPlaylist(" + _list[i].songid + ",'" + _list[i].songtype + "')\" title=\"移除\" class=\"del\">1</a>"
}
b += "</span></div>"
}
_$("#list_ScrollContent").html(b);
_$(".action_shop a.share").mouseover(function(a) {
mouse(this, a)
})
}
initCss();
$customScroll($("list_ScrollBox"), $("list_ScrollContent"), {
backgroundColor: "#fff",
scrollbgColor: "#D8EFD7",
scrollWidth: 5
})
}
function delFromPlaylist(a, b) {
if (_list.length > 0) {
for (var i = 0; i < _list.length; i++) {
if (a == _list[i].songid && b == _list[i].songtype) {
if (isCurrentList()) {
_list.splice(i, 1);
wsplayer.remove(i)
} else {
_list.splice(i, 1)
}
saveData(sing.cookie, escape(JSON.stringify(_list)));
getPlaylistHtml();
selectIndex();
_$(".play_list").html("<span class=\"play\">播放列表</span><b>(" + _list.length + ")</b>");
break
}
}
}
}
function clear_p() {
if (_list.length > 0 && _list[0].listindex == 0) {
var a = "<div style=\" text-align:center; font-size:16px; margin:120px auto 0;\">播放列表为空,<a href=\"/m/?abc=11\" style=\" color:#6DB823\">随便听听</a>!</div>";
_$("#list_ScrollBox").append(a);
_$("#musicplay").html("<span class=\"play\">播放列表</span><b>(0)</b>")
}
_list = [];
if (isCurrentList()) {
wsplayer.remove();
wsplayer.setPlayList(_list)
}
saveData(sing.cookie, JSON.stringify(_list));
_$("#list_ScrollContent div").remove()
}
function clear() {
_list = [];
_$("#list_ScrollContent div").remove()
}
function getPlaylist(a) {
var b = loadData(a);
if (b != null && b.length > 0) {
_list = JSON.parse(unescape(b))
}
return _list
}
function addToPlaylist(a, b, c, d, e, f, g, h) {
var j = false;
var k = false;
b = b.replaceSymbol();
var l = {
songname: b,
songid: c,
song: d,
hit: e,
songtype: f,
mp3: a,
listindex: h,
songID: c,
songType: f,
file: a,
singerID: g
};
if (_list.length > 0) {
for (var i = 0; i < _list.length; i++) {
if (a == _list[i].mp3) {
j = true;
return j
}
}
}
_list.push(l);
return j
}
function playlist(o) {
var a = _$(o).attr("id");
if (a == "musicbox") {
if (!sing.isLogin) {
singLogin();
return
}
if (sing.countMusicbox == -1) {
getMusicCount()
}
if (sing.countMusicbox > 0) {
_$("#btn_remove").hide();
_$("#musicplay").removeClass("play_list");
_$("#musicbox").attr("class", "share_list");
clear();
sing.setCurrentCookie(sing.cookieList.MusicBox);
getPlaylist(sing.cookie);
if (_list.length == 0 || _list.length != sing.countMusicbox) {
initMusicList()
} else {
getPlaylistHtml()
}
}
} else {
_$("#btn_remove").show();
_$("#musicplay").attr("class", "play_list");
_$("#musicbox").removeClass("share_list");
clear();
sing.setCurrentCookie(sing.cookieList.PlayList);
getPlaylist(sing.cookie);
getPlaylistHtml()
}
selectIndex()
}
function initMusicList() {
var a = 2;
_$.ajax({
async: false,
type: "post",
url: "m.ashx?rand=" + Math.random(),
data: "cmd=" + a,
dataType: "json",
success: function(o) {
if (o.status == 1) {
_list = [];
for (var i = 0; i < o.datas.length; i++) {
addToPlaylist(o.datas[i].songurl, o.datas[i].songname, o.datas[i].songid, o.datas[i].song, o.datas[i].hit, o.datas[i].songtype, o.datas[i].userid, sing.listIndex.MusicBox)
}
saveData(sing.cookie, escape(JSON.stringify(_list)));
getPlaylistHtml();
_$("#musicbox").html("<span class=\"share\">我的音乐盒</span><b>(" + _list.length + ")</b>")
}
}
})
}
function initPlayList() {
var a = 1;
_$.ajax({
async: false,
type: "post",
url: "m.ashx?rand=" + Math.random(),
data: "cmd=" + a + "&ids=" + _ids,
dataType: "json",
success: function(o) {
if (o.status == 1) {
_list = [];
for (var i = 0; i < o.datas.length; i++) {
addToPlaylist(o.datas[i].songurl, o.datas[i].songname, o.datas[i].songid, o.datas[i].song, o.datas[i].hit, o.datas[i].songtype, o.datas[i].userid, sing.listIndex.PlayList)
}
saveData(sing.cookieList.PlayList, escape(JSON.stringify(_list)))
}
}
})
}
function getMusicCount() {
var a = 20;
_$.ajax({
async: false,
type: "post",
url: "m.ashx?rand=" + Math.random(),
data: "cmd=" + a,
dataType: "json",
success: function(o) {
sing.countMusicbox = o.count
}
})
}
function getAgent() {
var a = 13;
_$.ajax({
async: false,
type: "post",
url: "m.ashx?rand=" + Math.random(),
data: "cmd=" + a,
dataType: "json",
success: function(o) {
sing.agent = o.status
}
})
}
function initHtml() {
getPlaylistHtml();
_$("#musicplay").html("<span class=\"play\">播放列表</span><b>(" + _list.length + ")</b>");
if (sing.countMusicbox == -1) {
getMusicCount();
_$("#musicbox").html("<span class=\"share\">我的音乐盒</span><b>(" + sing.countMusicbox + ")</b>");
if (sing.countMusicbox > 0) {
sing.isLogin = true
}
}
}
function getPlaylistIndex(a) {
index = -1;
if (_list.length > 0) {
for (var i = 0; i < _list.length; i++) {
if (_list[i].mp3 == a) {
index = i
}
}
}
return index
}
function isCurrentList() {
if (_list.length > 0 && wsplayer.playList.length == _list.length) {
if (_list[0].listindex == wsplayer.playList[0].listindex) {
return true
}
}
return false
}
function playsong(o) {
if (!isCurrentList()) {
wsplayer.setPlayList(_list);
wsplayer.playIndex = -1
}
var a = _$(o).attr("url");
wsplayer.play(getPlaylistIndex(a))
}
function getSongInfo(b, c) {
var d = 5;
_$.get('m.ashx', {
"cmd": d,
"id": b,
"type": c
},
function(a) {
if (a.status == 1) {
_$(".head").html("<a href=\"http://" + a.userid + ".xxxxx.com\" target=\"_blank\"><img alt=\"\" src=\"" + a.img + "\" /></a>");
if (a.love == 1) {
_$("#jp-like").removeClass("jp-like").addClass("jp-love")
} else {
_$("#jp-like").removeClass().addClass("jp-like")
}
}
},
"json");
initLrc(b, c)
}
function _down(o) {
if (_list.length > 0 && sing.playIndex >= 0 && sing.playIndex < _list.length) {
_$(o).attr("target", "_blank");
_$(o).attr("href", 'http://' + _list[sing.playIndex].songtype + '.xxxxx.com/Down.aspx?sid=' + _list[sing.playIndex].songid)
}
}
function _like() {
if (_list.length > 0 && sing.playIndex >= 0 && sing.playIndex < _list.length) {
like(_list[sing.playIndex].songid, _list[sing.playIndex].songtype)
}
}
function like(b, c) {
var d = 7;
_$.get('m.ashx', {
"cmd": d,
"id": b,
"type": c
},
function(a) {
switch (a.status) {
case 0:
alert('你没有登录');
break;
case 1:
_$("#jp-like").removeClass("jp-like").addClass("jp-love");
break;
case 11:
alert('已喜欢了');
break
}
},
"json")
}
function share(o, v) {
var a = parseInt(_$(o).attr("shareID"));
var b = null;
if (v == 1) {
var c = _$(o).parent().attr("mp3");
var d = getPlaylistIndex(c);
b = _list[d]
} else if (sing.playIndex >= 0) {
b = wsplayer.playList[sing.playIndex]
}
if (b != null) {
var e;
var f = "http://" + b.songtype + ".xxxxx.com/" + b.songid + ".html";
var g = b.songname;
switch (a) {
case 1:
e = "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=" + f;
break;
case 2:
e = "http://v.t.sina.com.cn/share/share.php?title=" + encodeURIComponent('我正在收听' + g + '') + "&url=" + f + "&source=bookmark&appkey=3432766229";
break;
case 3:
e = "http://v.t.qq.com/share/share.php?title=" + encodeURIComponent('我正在收听' + g + '') + "&url=" + f + "&appkey=edcceb2d877d4ec4ac9bb7705434ca17&site=音乐";
break;
case 4:
e = "http://tieba.baidu.com/f/commit/share/openShareApi?url=" + f + "&title=" + encodeURIComponent(g);
break;
case 5:
e = "http://share.renren.com/share/buttonshare.do?link=" + f + "&title=" + encodeURIComponent('我正在收听' + g + '');
break;
case 6:
e = "http://www.kaixin001.com/repaste/share.php?rtitle=" + encodeURIComponent('我正在收听' + g + '') + "&rurl=" + f;
break;
case 7:
e = "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?to=pengyou&url=" + f + "&title=" + encodeURIComponent('我正在收听' + g + '');
break;
case 8:
e = "http://shuo.douban.com/%21service/share?href=" + f + "&name=" + encodeURIComponent('我正在收听' + g + '');
break
}
openwin(e, true)
}
}
function singUserStatus() {
GetJSON("网址", "Command=UserStatus&url=" + window.location,
function(a) {
if (a.user.login) {
sing.isLogin = true;
var b = "<a href=\"http://www.xxxxx.com\" target=\"_blank\" title=\"音乐 \" class=\"logo\"></a>";
b += '欢迎,<a href=\"http://' + a.user.userid + '.xxxxx.com\" class="cgreen" target="_blank">' + a.user.nickname + '</a>';
b += '|<a href="网址logout.aspx" rel="nofollow">安全退出</a>';
_$(".box_header").html(b);
getMusicCount();
_$("#musicbox").html("<span class=\"share\">我的音乐盒</span><b>(" + sing.countMusicbox + ")</b>")
}
})
}
function singLogin() {
if (!sing.isLogin) {
_$.fancybox.open({
href: '网址',
type: 'iframe',
padding: 0,
width: 442,
height: 257
})
}
}
function GetJSON(b, c, d) {
_$.getJSON(b + "?jsoncallback=?", c,
function(a) {
d(a)
})
}
function openwin(b, c) {
var a = document.createElement("a");
a.setAttribute("href", b);
if (c) {
a.setAttribute("target", "_blank")
}
a.setAttribute("id", "openwin");
document.body.appendChild(a);
a.click()
}
function saveData(k, v) {
if (window.localStorage) {
c.SetValue(k, v)
} else {
flash.set(k, v)
}
}
function loadData(k) {
if (window.localStorage) {
return c.GetValue(k)
} else {
return flash.get(k)
}
}
function getwsPosition() {
var a = wsplayer.getCurrentTime();
if (a == undefined) {
return 0
}
return parseInt(a.toFixed(3) * 1000)
}
function mouse(o, a) {
var b = _$(document).height();
var c = a.pageY;
if (c < (b * 4 / 5)) {
_$(o).find(".weibo_btn").removeClass(" weibo_btn_t");
_$(o).find(".str").removeClass(" str_t")
} else {
_$(o).find(".weibo_btn").addClass(" weibo_btn_t");
_$(o).find(".str").addClass(" str_t")
}
}
[/code]
第4个文件
[code=javascript]
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(a, b) {
var n = this.length >>> 0,
i = ~~b;
if (i < 0) i += n;
for (; i < n; i++) if (i in this && this[i] === a) return i;
return - 1
}
}
var $wsp = $wsp || {};
$wsp.version = "1.1.0";
$wsp.$ = jQuery || {};
$wsp.plugins = {
silverlight: {
version: [4, 0],
types: ['wma', 'mp3']
},
flash: {
version: [9, 0],
types: ['mp3']
},
wmp: {
version: [0, 0],
types: ['mp3', "wma"]
}
};
$wsp.enabledPlugins = [];
$wsp.pluginMediaElements = {};
$wsp.htmlMediaElement = null;
if (typeof Audio != "undefined") {
$wsp.htmlMediaElement = new Audio();
$wsp.htmlMediaElement.preload = "load";
$wsp.htmlMediaElement.autoplay = true
} else {
$wsp.htmlMediaElement = {
canPlayType: function(a) {
return ""
}
}
}
$wsp.htmlMediaElement.isInited = false;
$wsp.utility = {};
$wsp.utility.addEventListener = function(a, b, c) {
if (window.addEventListener) {
a.addEventListener(b, c, false)
} else {
a.attachEvent(b, c)
}
};
$wsp.utility.secondsToTimeCode = function(a, b) {
var c = Math.floor(a / 3600) % 24,
minutes = Math.floor(a / 60) % 60,
seconds = Math.floor(a % 60);
var d = ((b || c > 0) ? (c < 10 ? '0' + c: c) + ':': '') + (minutes < 10 ? '0' + minutes: minutes) + ':' + (seconds < 10 ? '0' + seconds: seconds);
return d
};
$wsp.utility.escapeHTML = function(s) {
return s.toString().split('&').join('&').split('<').join('<').split('"').join('"')
};
$wsp.utility.addPlugin = function(p, a, b, c, d) {
var f = [0, 0, 0],
description,
i,
ax;
var g = window.navigator;
if (typeof(window.navigator.plugins) != 'undefined' && typeof window.navigator.plugins[a] == 'object') {
description = window.navigator.plugins[a].description;
if (description && !(typeof window.navigator.mimeTypes != 'undefined' && window.navigator.mimeTypes[b] && !window.navigator.mimeTypes[b].enabledPlugin)) {
f = description.replace(a, '').replace(/^\s+/, '').replace(/\sr/gi, '.').split('.');
for (i = 0; i < f.length; i++) {
f[i] = parseInt(f[i].match(/\d+/), 10)
}
}
} else if (typeof(window.ActiveXObject) != 'undefined') {
try {
ax = new ActiveXObject(c);
if (ax) {
f = d(ax)
}
} catch(e) {}
}
if ($wsp.plugins[p]) {
if (f[0] >= $wsp.plugins[p].version[0]) $wsp.enabledPlugins.push({
name: p,
version: f,
types: $wsp.plugins[p].types
})
}
};
$wsp.utility.absolutizeUrl = function(a) {
var b = document.createElement('div');
b.innerHTML = '<a href="' + $wsp.utility.escapeHTML(a) + '">x</a>';
return b.firstChild.href
};
$wsp.utility.isSong = function(a) {
if (typeof(a) == "string") {
var i = a.lastIndexOf(".mp3");
var j = a.lastIndexOf(".wma");
if ((i > 0 && a.substring(i) == ".mp3") || (j > 0 && a.substring(j) == ".wma")) return true
}
return false
};
$wsp.utility.getFile = function(a) {
var b = null;
if (typeof(a) == "string" && $wsp.utility.isSong(a)) {
b = a
} else if (typeof(a) == "object") {
$wsp.$.each(a,
function(k, v) {
if ($wsp.utility.isSong(v)) b = v
})
}
return b
};
$wsp.utility.isWMPEnabled = function() {
var a;
try {
if (window.ActiveXObject) {
a = new ActiveXObject("WMPlayer.OCX.7")
}
} catch(oError) {}
return a
};
if ($wsp.utility.isWMPEnabled()) {
$wsp.enabledPlugins.push({
name: "wmp",
version: [0, 0],
types: $wsp.plugins["wmp"].types
})
}
$wsp.utility.addPlugin('flash', 'Shockwave Flash', 'application/x-shockwave-flash', 'ShockwaveFlash.ShockwaveFlash',
function(a) {
var b = [],
d = a.GetVariable("$version");
if (d) {
d = d.split(" ")[1].split(",");
b = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]
}
return b
});
$wsp.utility.addPlugin('silverlight', 'Silverlight Plug-In', 'application/x-silverlight-2', 'AgControl.AgControl',
function(b) {
var v = [0, 0, 0, 0],
loopMatch = function(a, v, i, n) {
while (a.isVersionSupported(v[0] + "." + v[1] + "." + v[2] + "." + v[3])) {
v[i] += n
}
v[i] -= n
};
loopMatch(b, v, 0, 1);
loopMatch(b, v, 1, 1);
loopMatch(b, v, 2, 10000);
loopMatch(b, v, 2, 1000);
loopMatch(b, v, 2, 100);
loopMatch(b, v, 2, 10);
loopMatch(b, v, 2, 1);
loopMatch(b, v, 3, 1);
return v
});
$wsp.utility.getValueFromCookie = function(a) {
var b = a + "=";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(b);
if (offset != -1) {
offset += b.length;
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(offset, end))
}
}
return ""
};
$wsp.utility.deleteValueFromCookie = function(a) {
var b = new Date();
b.setTime(b.getTime() - 1);
var c = $wsp.utility.getValueFromCookie(a);
if (c != null) document.cookie = a + "=" + c + "; expires=" + b.toGMTString() + "; domain=/; path=/"
};
$wsp.utility.setValueToCookie = function(a, b) {
$wsp.utility.deleteValueFromCookie(a);
var c = 365;
var d = new Date();
d.setTime(d.getTime() + c * 24 * 60 * 60 * 1000);
document.cookie = a + "=" + escape(b) + "; expires=" + d.toGMTString() + "; domain=/; path=/"
};
$wsp.utility.getVolumeFromCookie = function() {
return parseFloat($wsp.utility.getValueFromCookie("wsp_volume"))
};
$wsp.utility.setVolumeToCookie = function(a) {
$wsp.utility.setValueToCookie("wsp_volume", a)
};
$wsp.utility.getIsMutedFromCookie = function() {
var v = parseInt($wsp.utility.getValueFromCookie("wsp_ismuted"));
return v == 1
};
$wsp.utility.setIsMutedToCookie = function(a) {
$wsp.utility.setValueToCookie("wsp_ismuted", a ? "1": "0")
};
$wsp.mediaHelper = {};
$wsp.mediaHelper.blockWMP = function() {
$wsp.utility.setValueToCookie("disableWMP", "1");
window.location.replace(location.href)
};
$wsp.mediaHelper.initPlugin = function(a) {
var b = $wsp.pluginMediaElements[a];
if (b) {
if (b.pluginType == "flash") b.pluginApi = b.pluginElement = document.getElementById(a);
else if (b.pluginType == "silverlight") {
b.pluginElement = document.getElementById(a);
b.pluginApi = b.pluginElement.Content.API
}
if (b.pluginApi != null) b.successToInitPlugin(b)
}
};
$wsp.mediaHelper.canAutoplay = function(a) {
if (typeof a.pluginId == "undefined") {
var b = window.navigator.userAgent.toLowerCase();
var c = b.match(/ipad/) || b.match(/iphone/);
return ! c
}
return true
};
$wsp.mediaHelper.mediaMimeType = {
"mp3": ['audio/mp3', 'audio/mpeg'],
"wma": ['audio/x-ms-wma', 'audio/wma']
};
$wsp.mediaHelper.createPlugin = function(b, c, d, e, f, g) {
var h = b.substring(b.lastIndexOf(".") + 1);
var j = $wsp.mediaHelper.mediaMimeType[h];
var k = false;
$wsp.$.each(j,
function(i, a) {
if ($wsp.htmlMediaElement.canPlayType(a).replace(/no/, '') !== '') {
k = true
}
});
if (k) {
if (!$wsp.htmlMediaElement.isInited) {
var l = {
setCurrentTime: function(a) {
this.currentTime = a
},
setMuted: function(a) {
this.muted = a
},
setVolume: function(a) {
this.volume = a
},
stop: function() {
this.pause();
this.currentTime = 0
},
setSrc: function(a) {
if (typeof a == 'string') this.src = a
}
};
for (var o in l) $wsp.htmlMediaElement[o] = l[o];
$wsp.htmlMediaElement.isInited = true;
g($wsp.htmlMediaElement)
}
$wsp.htmlMediaElement.setVolume(c);
$wsp.htmlMediaElement.setSrc(b);
$wsp.htmlMediaElement.load();
return $wsp.htmlMediaElement
} else {
var m = {};
$wsp.$.each($wsp.enabledPlugins,
function(i, a) {
if (a.types.indexOf(h) >= 0) {
m[a.name] = 1
}
});
var n = "wsp_player_" + new Date().getTime();
var p = $wsp.utility.getValueFromCookie("disableWMP");
if (m["wmp"] && $wsp.$.browser.msie && p != "1") {
$wsp.pluginMediaElements[n] = new $wsp.pluginMedia(n, "wmp", b, c, d, e, f);
var q = document.getElementById(n);
$wsp.pluginMediaElements[n].pluginApi = {
playMedia: function() {
q.controls.play()
},
pauseMedia: function() {
q.controls.pause()
},
setSrc: function(a) {
q.currentMedia = q.newMedia(a)
},
setCurrentTime: function(a) {
q.controls.currentPosition = a
},
setVolume: function(a) {
q.settings.volume = a * 100
},
setMuted: function(a) {
q.settings.mute = a
}
}
} else if (m["flash"]) $wsp.pluginMediaElements[n] = new $wsp.pluginMedia(n, "flash", b, c, d, e, f);
else if (m["silverlight"]) $wsp.pluginMediaElements[n] = new $wsp.pluginMedia(n, "silverlight", b, c, d, e, f);
else return null;
if (typeof g == "function") {
$wsp.pluginMediaElements[n].successToInitPlugin = g;
if ($wsp.pluginMediaElements[n] != null && $wsp.pluginMediaElements[n].pluginType == "wmp") g($wsp.pluginMediaElements[n])
} else $wsp.pluginMediaElements[n].successToInitPlugin = function() {};
return $wsp.pluginMediaElements[n]
}
};
$wsp.mediaHelper.fireEvent = function(b, c, d) {
var f = $wsp.pluginMediaElements[b];
var e = {
type: c,
target: f
};
if (f) {
for (var v in d) {
f[v] = d[v];
e[v] = d[v]
}
e.buffered = e.target.buffered = {
start: function(a) {},
end: function(a) {
return e.bufferedTime || 0
},
length: 1
};
f.dispatchEvent(e.type, e)
}
};
$wsp.mediaHelper.createContainer = function(a) {
var b = a + "_container";
return $wsp.$('<div id="' + b + '" style="width:1px; height:1px; line-height:0; font-size:0; overflow:hidden; position:absolute;top:-9999px; left:-9999px;"></div>').appendTo("body")
};
$wsp.mediaHelper.destory = function(a) {
if (a) {
a.pause();
if (typeof a.pluginId == "undefined") {
a.setSrc("")
} else {
var b = document.getElementById(a.pluginId);
var c = $wsp.$(b).parent();
if (b && (b.nodeName == "OBJECT" || b.nodeName == "EMBED")) {
if ($wsp.$.browser.msie) {
b.style.display = "none"; (function() {
if (b.readyState == 4) {
if (b) {
for (var i in b) {
if (typeof b[i] == "function") {
b[i] = null
}
}
b.parentNode.removeChild(b);
c.remove()
}
} else {
setTimeout(arguments.callee, 10)
}
})()
} else {
b.parentNode.removeChild(b);
c.remove()
}
}
delete $wsp.pluginMediaElements[a.pluginId]
}
}
};
$wsp.pluginMedia = function(c, d, e, f, g, h, i) {
this.pluginId = c;
this.pluginType = d;
this.autoplay = false;
this.pluginApi = null;
this.pluginElement = null;
this.paused = true;
this.src = null;
this.volume = f;
this.muted = false;
this.currentTime = 0;
this.buffered = {
start: function(a) {
return 0
},
end: function(a) {
return 0
},
length: 1
};
this.duration = 0;
this.events = {};
this.wmp_Buffer = null;
this.wmp_TimeUpdate = null;
var j = this;
this.play = function() {
if (this.pluginApi != null) {
this.paused = false;
this.pluginApi.playMedia()
}
return this
};
this.pause = function() {
if (this.pluginApi != null) {
this.paused = true;
this.pluginApi.pauseMedia()
}
return this
};
this.setSrc = function(a) {
if (typeof a == 'string') {
this.src = $wsp.utility.absolutizeUrl(a);
this.pluginApi.setSrc($wsp.utility.absolutizeUrl(a))
}
return this
};
this.setCurrentTime = function(a) {
if (this.pluginApi != null) {
this.pluginApi.setCurrentTime(a);
this.currentTime = a
}
return this
};
this.setVolume = function(a) {
if (this.pluginApi != null) {
this.pluginApi.setVolume(a);
this.volume = a
}
return this
};
this.setMuted = function(a) {
if (this.pluginApi != null) {
this.pluginApi.setMuted(a);
this.muted = a
}
return this
};
this.addEventListener = function(a, b) {
this.events[a] = b;
return this
};
this.dispatchEvent = function(a) {
var b, callbacks = this.events[a];
if (typeof(callbacks) == "function") {
b = Array.prototype.slice.call(arguments, 1);
if (b.length > 0) callbacks(b[0])
}
return this
};
var k = "";
var l = ['id=' + this.pluginId, 'autoplay=' + ((this.autoplay) ? "true": "false"), 'startvolume=' + f, 'timerate=' + g];
e = (e !== null) ? $wsp.utility.absolutizeUrl(e) : '';
if (e) {
if (this.pluginType == 'flash') l.push('file=' + encodeURI(e));
else l.push('file=' + e)
}
switch (this.pluginType) {
case "silverlight":
k = '<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" id="' + this.pluginId + '" name="' + this.pluginId + '" >' + '<param name="initParams" value="' + l.join(',') + '" />' + '<param name="autoUpgrade" value="true" />' + '<param name="enableHtmlAccess" value="true" />' + '<param name="source" value="' + h + i["silverlight"] + '?' + new Date().getTime() + '" />' + '</object>';
break;
case "flash":
if ($wsp.$.browser.msie) {
k = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ' + 'id="' + this.pluginId + '" name="' + this.pluginId + '">' + '<param name="movie" value="' + h + i["flash"] + '?' + new Date().getTime() + '" />' + '<param name="flashvars" value="' + l.join('&') + '" />' + '<param name="allowScriptAccess" value="always" />' + '</object>'
} else {
k = '<embed id="' + this.pluginId + '" name="' + this.pluginId + '" ' + 'allowScriptAccess="always" ' + 'type="application/x-shockwave-flash" pluginspage="//www.macromedia.com/go/getflashplayer" ' + 'src="' + h + i["flash"] + '?' + new Date().getTime() + '" ' + 'flashvars="' + l.join('&') + '"></embed>'
}
break;
case "wmp":
k = '<object id="' + this.pluginId + '" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject">' + '<param name="AutoStart" value="0" />' + '<param name="URL" value="' + e + '" />' + '<param name="volume" value="80" />' + '</object>';
break
}
$wsp.mediaHelper.createContainer(c).appendTo("body").html(k)
};
$wsp.mediaElement = function(j, k) {
var l = $wsp.$(j);
var m = {
loopMode: 1,
startVolume: 0.8,
autoplay: true,
timeRate: 200,
playList: [],
isSyncVolume: true,
pluginPath: "/skin/jquery/js/",
pluginFiles: {
silverlight: "slPlayer.xap",
flash: "fplayer.swf"
},
loading: l.find(".wsp_loading"),
stats: {
enable: false,
url: "/e/action/ShowInfo.php",
interval: 10000,
source: 0,
referer: document.referrer,
currentPage: window.location.href
},
control: {
prev: l.find(".wsp_c_prev"),
play: l.find(".wsp_c_play"),
pause: l.find(".wsp_c_pause"),
next: l.find(".wsp_c_next"),
playStateChanged: function(a) {
if (a && a.paused) {
m.control.play.show();
m.control.pause.hide()
} else {
m.control.play.hide();
m.control.pause.show()
}
},
cannotAutoplay: function() {
m.control.play.show();
m.control.pause.hide()
}
},
progressBar: {
current: l.find(".wsp_p_current"),
buffered: l.find(".wsp_p_buffered"),
total: l.find(".wsp_p_total")
},
volume: {
mute: l.find(".wsp_v_mute"),
mutedClass: "wsp_v_mute_sel",
current: l.find(".wsp_v_current"),
total: l.find(".wsp_v_total"),
muteStateChanged: function(a) {}
},
currentTimeLabel: l.find(".wsp_currentTime"),
TotalTimeLabel: l.find(".wsp_totaltime"),
errorToPlay: function(a) {},
unsupport: function(a) {},
playIndexChanged: function(a, b) {},
customInit: function(a, b) {}
};
m = $wsp.$.extend(true, {},
m, k);
if (m.isSyncVolume) {
var n = $wsp.utility.getVolumeFromCookie();
if (isNaN(n)) $wsp.utility.setVolumeToCookie(m.startVolume);
else m.startVolume = n
}
if (m.startVolume < 0 || m.startVolume > 1) {
m.startVolume = 1;
$wsp.utility.setVolumeToCookie(m.startVolume)
}
var o = this;
this.playList = [];
this.playIndex = -1;
this.loopMode = m.loopMode;
var p = false;
p = $wsp.utility.getIsMutedFromCookie();
var q = null;
var r = {
"songID": NaN,
"songType": null,
"file": null,
"songName": null,
"singerID": NaN,
"singer": null,
"avatar": null
};
var s = function(b) {
if (b) {
if (typeof(b) == "string") o.playList.push($wsp.$.extend(true, {},
r, {
"file": b
}));
else if (Object.prototype.toString.apply(b) === '[object Array]') $wsp.$.each(b,
function(i, a) {
if (typeof(a) == "string") o.playList.push($wsp.$.extend(true, {},
r, {
"file": a
}));
else if (typeof(a) == "object") o.playList.push($wsp.$.extend(true, {},
r, a))
});
else if (typeof(b) == "object") o.playList.push($wsp.$.extend(true, {},
r, b))
}
};
this.setPlayList = function(a, b) {
o.playList = [];
s(a);
if (typeof b == "number" && b >= 0 && b < o.playList.length) {
o.playIndex = -1;
o.play(b)
}
return o
};
this.add = function(a, b) {
s(a);
if (b) o.play(o.playList.length - 1);
return o
};
this.remove = function(a) {
o.playList.splice(a, 1);
return o
};
this.clear = function() {
o.playList = [];
return o
};
this.setLoopMode = function(a) {
if (a != undefined) {
if (a != 0 && a != 1) a = 1;
o.loopMode = a
} else {
o.loopMode = (o.loopMode + 1) % 2
}
return o
};
this.getCurrentTime = function() {
if (q) return q.currentTime;
else return 0
};
this.playMedia = function() {
if (q != null) q.play()
};
this.pauseMedia = function() {
if (q != null) q.pause()
};
var t = 0;
var u = function(b) {
if (o.playIndex >= 0) {
var c = o.getCurrentTime();
var d = o.playList[o.playIndex];
if (typeof d != undefined && c > t) {
t = c;
if (b == undefined) b = false;
var e = {
ID: d.songID,
classid: d.songType,
singerID: d.singerID,
source: m.stats.source,
referer: m.stats.referer,
currentPage: m.stats.currentPage,
currentTime: c,
totalTime: q != undefined && q != null ? q.duration: 0,
isEnd: b
};
if (!isNaN(e.songID) && e.songType != null && !isNaN(e.singerID)) {
$wsp.$.getJSON(m.stats.url, e,
function(a) {})
}
}
}
};
var v = null;
this.play = function(g) {
if (o.playList.length > 0 && typeof(g) == "number" && g >= 0 && g < o.playList.length && o.playIndex != g) {
if (q && q.pluginType != "wmp") {
$wsp.mediaHelper.destory(q);
q = null
}
o.playIndex = g;
var h = o.playList[o.playIndex];
m.currentTimeLabel.html("00:00");
m.TotalTimeLabel.html("00:00");
m.progressBar.current.width(0);
m.progressBar.buffered.width(0);
m.playIndexChanged(g, h);
var i = h.file;
if (i) {
if (q != null) {
q.setSrc(i);
q.play()
} else {
q = $wsp.mediaHelper.createPlugin(i, m.startVolume, m.timeRate, m.pluginPath, m.pluginFiles,
function(d) {
if (d.pluginType == "wmp") {
var f = document.getElementById(d.pluginId);
f.attachEvent("Error",
function() {
if ($wsp.utility.isSong(d.src) || d.pluginId != undefined) m.errorToPlay(o)
});
f.attachEvent("MediaError",
function(a) {
if ($wsp.utility.isSong(d.src) || d.pluginId != undefined) m.errorToPlay(o)
});
f.attachEvent("OpenStateChange",
function(a) {
m.loading.show()
});
f.attachEvent("Buffering",
function(a) {
m.loading.show()
});
f.attachEvent("PlayStateChange",
function(a) {
switch (a) {
case 2:
m.control.playStateChanged(q);
m.loading.hide();
if (v != null) {
clearInterval(v);
v = null
}
break;
case 3:
m.control.playStateChanged(q);
m.loading.hide();
if (q) q.setMuted(p);
if (v == null && m.stats.enable) v = setInterval(u, m.stats.interval);
break;
case 6:
case 7:
m.loading.show();
break;
case 8:
u(true);
break;
default:
break
}
});
if (d.wmp_TimeUpdate == null) {
d.wmp_TimeUpdate = setInterval(function() {
try {
if (!q.paused && f.playState == 1) {
if (o.loopMode == 0 || o.playList.length <= 1) {
m.stats.enable = false;
q.setSrc(i);
q.play()
} else {
var b = o.playIndex + 1;
if (b >= o.playList.length) b = 0;
o.play(b)
}
}
d.duration = f.currentMedia.duration;
d.buffered = {
start: function(a) {
return 0
},
end: function(a) {
return f.network.downloadProgress * f.currentMedia.duration / 100
},
length: 1
};
d.currentTime = f.controls.currentPosition;
var w = parseInt(m.progressBar.total.width() * f.controls.currentPosition / d.duration);
if (w != NaN) m.progressBar.current.width(w);
m.currentTimeLabel.html($wsp.utility.secondsToTimeCode(f.controls.currentPosition));
if (d.duration > 0 && m.TotalTimeLabel.html() == "00:00") m.TotalTimeLabel.html($wsp.utility.secondsToTimeCode(d.duration));
var c = m.progressBar.total.width();
var w = parseInt(c * f.network.downloadProgress / 100);
if (w != NaN) m.progressBar.buffered.width(w)
} catch(ex) {}
},
250)
}
} else {
d.addEventListener("loadstart",
function(e) {
m.loading.show()
});
d.addEventListener("loadedmetadata",
function(e) {
if (e.target.duration > 0) m.TotalTimeLabel.html($wsp.utility.secondsToTimeCode(e.target.duration));
m.loading.hide()
});
d.addEventListener("canplay",
function(e) {
if (m.autoplay && $wsp.mediaHelper.canAutoplay(d) && e.target.paused) {
d.play()
}
});
d.addEventListener("canplaythrough",
function(e) {
m.progressBar.buffered.width(m.progressBar.total.width())
});
d.addEventListener("progress",
function(e) {});
d.addEventListener("timeupdate",
function(e) {
var w = parseInt(m.progressBar.total.width() * e.target.currentTime / e.target.duration);
if (w != NaN) m.progressBar.current.width(w);
m.currentTimeLabel.html($wsp.utility.secondsToTimeCode(e.target.currentTime));
if (e.target.duration > 0 && m.TotalTimeLabel.html() == "00:00") m.TotalTimeLabel.html($wsp.utility.secondsToTimeCode(e.target.duration));
try {
if (e.target.buffered && e.target.buffered.length > 0) {
var a = m.progressBar.total.width();
var w = parseInt(a * e.target.buffered.end(0) / e.target.duration);
if (w != NaN) m.progressBar.buffered.width(w)
}
} catch(ex) {}
});
d.addEventListener("loadeddata",
function(e) {});
d.addEventListener("error",
function(e) {
if ($wsp.utility.isSong(e.target.src) || e.target.pluginId != undefined) m.errorToPlay(o)
});
d.addEventListener("play",
function(e) {
m.control.playStateChanged(q);
m.loading.hide();
if (q) q.setMuted(p);
if (v == null && m.stats.enable) v = setInterval(u, m.stats.interval)
});
d.addEventListener("playing",
function(e) {
m.control.playStateChanged(q);
m.loading.hide();
if (v == null && m.stats.enable) v = setInterval(u, m.stats.interval)
});
d.addEventListener("pause",
function(e) {
m.control.playStateChanged(q);
m.loading.hide();
if (v != null) {
clearInterval(v);
v = null
}
});
d.addEventListener("ended",
function(e) {
u(true);
if (o.loopMode == 0 || o.playList.length <= 1) {
m.stats.enable = false;
e.target.play();
e.target.setCurrentTime(0.1)
} else {
var a = o.playIndex + 1;
if (a >= o.playList.length) a = 0;
o.play(a)
}
})
}
})
}
if (q == null || typeof q == undefined) m.unsupport(o)
} else m.errorToPlay(o)
}
return o
};
var y = function() {
m.control.prev.click(function() {
var i = o.playIndex - 1;
if (i < 0) i = o.playList.length - 1;
o.play(i)
});
m.control.play.click(function() {
if (q) q.play()
});
m.control.pause.click(function() {
if (q) q.pause()
});
m.volume.mute.click(function() {
if (q) {
q.setMuted(!q.muted);
p = q.muted;
if (m.isSyncVolume) {
$wsp.utility.setIsMutedToCookie(p)
}
if (m.volume.mutedClass) {
if (p && !$wsp.$(this).hasClass(m.volume.mutedClass)) {
$wsp.$(this).addClass(m.volume.mutedClass);
m.volume.current.width(0)
} else if (!p) {
$wsp.$(this).removeClass(m.volume.mutedClass);
m.volume.current.width(m.startVolume * m.volume.total.width())
}
}
if (typeof(m.volume.muteStateChanged) == "function") m.volume.muteStateChanged(q.muted)
}
});
m.control.next.click(function() {
var i = o.playIndex + 1;
if (i >= o.playList.length) i = 0;
o.play(i)
});
m.progressBar.total.click(function(e) {
var a = $wsp.$(this).offset().left;
var x = e.pageX;
m.progressBar.current.width(x - a);
if (q) {
var b = (x - a) * q.duration / $wsp.$(this).width();
q.setCurrentTime(b);
if (q.paused) q.play()
}
});
m.volume.total.click(function(e) {
var a = $wsp.$(this).offset().left;
var x = e.pageX;
m.volume.current.width(x - a);
p = false;
if (q) q.muted = false;
if (m.volume.mutedClass) m.volume.mute.removeClass(m.volume.mutedClass);
if (q) {
q.setVolume((x - a) / $wsp.$(this).width());
m.startVolume = (x - a) / $wsp.$(this).width();
if (m.isSyncVolume) $wsp.utility.setVolumeToCookie(m.startVolume)
}
});
if (p) {
if (m.volume.mutedClass) m.volume.mute.removeClass(m.volume.mutedClass).addClass(m.volume.mutedClass);
m.volume.current.width(0)
} else m.volume.current.width(m.startVolume * m.volume.total.width());
if (typeof(m.volume.muteStateChanged) == "function") m.volume.muteStateChanged(p);
if (typeof(m.customInit) == "function") m.customInit(o, q);
o.setPlayList(m.playList, 0);
if (m.autoplay) m.loading.show();
if (q) {
if (!m.autoplay || !$wsp.mediaHelper.canAutoplay(q)) {
m.control.cannotAutoplay();
m.loading.hide()
} else if (q.pluginType == "wmp") {
q.play()
}
}
return o
};
return y()
};
[/code]
音乐代码!
最新推荐文章于 2024-07-09 19:03:24 发布