//歌曲列表
var JJG = function(o){
this.setting = (typeof o === 'object') ? o : {};
this.target = this.setting.target || 'newSong';
this.type = typeof this.setting.type === 'number' ? this.setting.type : parseInt(this.setting.type);
this.firstCount = typeof this.setting.firstCount === 'number' ? this.setting.firstCount : parseInt(this.setting.firstCount);
this.Count = typeof this.setting.Count === 'number' ? this.setting.Count : parseInt(this.setting.Count);
this.content = $("#content");
//初始化
this.init();
}
JJG.prototype ={
init:function(){
//列表初始化
this.content.html("");
//堆栈指针初始化
this.stack = 0;
//图片路径
this.imgPath = 'data/';
//定时器
this.timer = null;
//测试JSON数据(可以替换为AJAX请求返回值)
this.testJson = {
list:[
{src:"/djcspic/thumb_149.png",title:"阳江DJ权仔【2024国粤语经典《浪人情歌》享受极限魅力包房车载DJ串烧】",titles:"阳江DJ权仔【2024国粤语经典《浪人情歌》享受极限魅力包房车载DJ串烧】",titlej:"1",song:"/lsdownmp3/csdjll5trrjkeogbjd.mp3",id:"ll5trrjkeogbjd",fl:"",aid:""},{src:"/djcspic/thumb_143.png",title:"精品国粤语郭有才诺言慢摇超重低音车载串烧CD625(横州DJ98Mix)",titles:"精品国粤语郭有才诺言慢摇超重低音车载串烧CD625(横州DJ98Mix)",titlej:"1",song:"/lsdownmp3/csdjvcijxssosamnjd.mp3",id:"vcijxssosamnjd",fl:"",aid:""},{src:"/djcspic/thumb_77.png",title:"DJ大宝-全中文PROG金牌车载弹鼓节奏热播诺言劲爆劲曲MUSIC慢摇大碟",titles:"DJ大宝-全中文PROG金牌车载弹鼓节奏热播诺言劲爆劲曲MUSIC慢摇大碟",titlej:"1",song:"/lsdownmp3/csdjbc7mskxadzujjd.mp3",id:"bc7mskxadzujjd",fl:"",aid:""},{src:"/djcspic/thumb_21.png",title:"阳江DJ权仔【2024全经典粤语老歌带DJ《Electro》享受极限魅力包房车载DJ串烧】",titles:"阳江DJ权仔【2024全经典粤语老歌带DJ《Electro》享受极限魅力包房车载DJ串烧】",titlej:"1",song:"/lsdownmp3/csdjrsxxrigq1ktfjd.mp3",id:"rsxxrigq1ktfjd",fl:"",aid:""},{src:"/djcspic/thumb_30.png",title:"阳江DJ权仔【2024抖(音)热播榜单中文《Electro》享受极限魅力包房车载DJ串烧】",titles:"阳江DJ权仔【2024抖(音)热播榜单中文《Electro》享受极限魅力包房车载DJ串烧】",titlej:"1",song:"/lsdownmp3/csdjjccbieajhz9ujd.mp3",id:"jccbieajhz9ujd",fl:"",aid:""},{src:"/djcspic/thumb_29.png",title:"阳江DJ权仔【2024抖(音)劲嗨全中文带DJ《Electro》享受极限魅力包房车载DJ串烧】",titles:"阳江DJ权仔【2024抖(音)劲嗨全中文带DJ《Electro》享受极限魅力包房车载DJ串烧】",titlej:"1",song:"/lsdownmp3/csdjjnhybb8dxzwnjd.mp3",id:"jnhybb8dxzwnjd",fl:"",aid:""},{src:"/djcspic/thumb_171.png",title:"韶关DJ阿其-国粤语Electro音乐曾经相爱的人多想把你抱住串烧",titles:"韶关DJ阿其-国粤语Electro音乐曾经相爱的人多想把你抱住串烧",titlej:"1",song:"/lsdownmp3/csdjih1lc8x5soejjd.mp3",id:"ih1lc8x5soejjd",fl:"",aid:""},{src:"/djcspic/thumb_128.png",title:"DJ大宝-全中文FUNKY金牌车载最美女声弥渡山歌女儿情咚鼓风暴MUSIC慢摇大碟",titles:"DJ大宝-全中文FUNKY金牌车载最美女声弥渡山歌女儿情咚鼓风暴MUSIC慢摇大碟",titlej:"1",song:"/lsdownmp3/csdj1dvbmm46km0qjd.mp3",id:"1dvbmm46km0qjd",fl:"",aid:""},{src:"/djcspic/thumb_76.png",title:" 现场{金钻甜歌后邓丽君}2024打造专辑 慢嗨DJ串烧",titles:" 现场{金钻甜歌后邓丽君}2024打造专辑 慢嗨DJ串烧",titlej:"1",song:"/lsdownmp3/csdjh4d8zguhjhlijd.mp3",id:"h4d8zguhjhlijd",fl:"",aid:""},{src:"/djcspic/thumb_74.png",title:"39韩宝仪金牌伤感情歌集DJ",titles:"39韩宝仪金牌伤感情歌集DJ",titlej:"1",song:"/lsdownmp3/csdjmfqt9xexdpb0jd.mp3",id:"mfqt9xexdpb0jd",fl:"",aid:""},{src:"/djcspic/thumb_155.png",title:"精品国潮国语因为爱情化风行万里慢摇超重低音车载串烧CD619(横州DJ98Mix)_2024512172647",titles:"精品国潮国语因为爱情化风行万里慢摇超重低音车载串烧CD619(横州DJ98Mix)_2024512172647",titlej:"1",song:"/lsdownmp3/csdjlcusxy3bhtxsjd.mp3",id:"lcusxy3bhtxsjd",fl:"",aid:""},{src:"/djcspic/thumb_71.png",title:"DJ龙二少 - 全中文DJ车载《九妹》重低音串烧舞曲",titles:"DJ龙二少 - 全中文DJ车载《九妹》重低音串烧舞曲",titlej:"1",song:"/lsdownmp3/csdjmdntnds3igp0jd.mp3",id:"mdntnds3igp0jd",fl:"",aid:""},{src:"/djcspic/thumb_70.png",title:"DJ龙二少 - 全中文DJ劲爆车载《朋友的酒》串烧舞曲",titles:"DJ龙二少 - 全中文DJ劲爆车载《朋友的酒》串烧舞曲",titlej:"1",song:"/lsdownmp3/csdjiocgdmyfs6q5jd.mp3",id:"iocgdmyfs6q5jd",fl:"",aid:""},{src:"/djcspic/thumb_69.png",title:"DJ龙二少 - 全中文DJ车载CD《枕边人我在等你》串烧舞曲",titles:"DJ龙二少 - 全中文DJ车载CD《枕边人我在等你》串烧舞曲",titlej:"1",song:"/lsdownmp3/csdjg33jg0kwnhh9jd.mp3",id:"g33jg0kwnhh9jd",fl:"",aid:""},{src:"/djcspic/thumb_68.png",title:"从化DJ杰仔-联手DJ珊珊打造全国语Club风格DJ小九专辑包房partyV1串烧",titles:"从化DJ杰仔-联手DJ珊珊打造全国语Club风格DJ小九专辑包房partyV1串烧",titlej:"1",song:"/lsdownmp3/csdjhbredazu4ouvjd.mp3",id:"hbredazu4ouvjd",fl:"",aid:""},{src:"/djcspic/thumb_67.png",title:"从化DJ杰仔-国粤语Club联手DJ珊珊你就是我想要的幸福包房串烧",titles:"从化DJ杰仔-国粤语Club联手DJ珊珊你就是我想要的幸福包房串烧",titlej:"1",song:"/lsdownmp3/csdjnkrplwgk53ldjd.mp3",id:"nkrplwgk53ldjd",fl:"",aid:""},{src:"/djcspic/thumb_66.png",title:"从化DJ杰仔-全粤语Club联手DJ珊珊打造爱是一场梦包房party串烧V3",titles:"从化DJ杰仔-全粤语Club联手DJ珊珊打造爱是一场梦包房party串烧V3",titlej:"1",song:"/lsdownmp3/csdjhmf9bzxb8qqnjd.mp3",id:"hmf9bzxb8qqnjd",fl:"",aid:""},{src:"/djcspic/thumb_65.png",title:"从化DJ杰仔-全粤语Club联手DJ珊珊打造沉默是金纪念张国荣21周年串烧",titles:"从化DJ杰仔-全粤语Club联手DJ珊珊打造沉默是金纪念张国荣21周年串烧",titlej:"1",song:"/lsdownmp3/csdjivccwb4c4gw6jd.mp3",id:"ivccwb4c4gw6jd",fl:"",aid:""},{src:"/djcspic/thumb_44.png",title:"阳江DJ权仔【2024全中文慢摇私货带DJ《FKHouse》享受极限魅力包房车载DJ串烧】",titles:"阳江DJ权仔【2024全中文慢摇私货带DJ《FKHouse》享受极限魅力包房车载DJ串烧】",titlej:"1",song:"/lsdownmp3/csdjkwwk48jqss7xjd.mp3",id:"kwwk48jqss7xjd",fl:"",aid:""},{src:"/djcspic/thumb_11.png",title:"韶关DJ阿其-国粤语Electro音乐就让秋风带走我的伤心带走我的泪串烧",titles:"韶关DJ阿其-国粤语Electro音乐就让秋风带走我的伤心带走我的泪串烧",titlej:"1",song:"/lsdownmp3/csdj7xkymjwpzicsjd.mp3",id:"7xkymjwpzicsjd",fl:"",aid:""},
]
}
this.createList(true);
this.addHandle();
},
//创建内容列表
createList:function(boolen){
//boolen:true/false确定是否初次载入,
this.ulNode = document.createElement("ul");
this.ulNode.id = this.target+"list";
this.content.append(this.ulNode);
this.ulTarget = $("#"+this.ulNode.id);
this.createMore();
this.loadList(boolen);
},
//创建更多按钮
createMore:function(){
this.moreNode = document.createElement("div");
this.moreNode.className = 'm';
this.moreNode.innerHTML = '加载更多...';
this.moreNode.id = this.target+'more';
this.moreTarget = $("#"+this.moreNode.id);
},
//加载列表
loadList:function(boolen){
var oList = this.testJson.list;
var oLength;
if(boolen){ //计算加载歌曲数
oLength = oList.length > this.firstCount ? this.firstCount: oList.length;
}else{
oLength = (oList.length-this.stack) > this.Count ? this.Count: (oList.length-this.stack);
}
if(oLength<=0){
location.href = '/djcsph4_2.html';
};
if(!this.moreTarget[0]){
this.content.append(this.moreNode);
};
for(var i = 0 ; i < oLength ; i++){
this.loadDate(oList);
}
},
//加载列表数据
loadDate:function(oList){
switch(this.type){
//根据不同的模块 定制不同的数据展示形式
case 1:this.ulTarget.append('
'
+ ''
+ '
'
//+ ''
+ ''
//+ ''
+ ''
+ ''+oList[this.stack].titles+'
'
+ '');
break;
case 2:this.content[0].innerHTML = '此模块建设中...';
break;
default :alert("该模块出错!");
}
this.stack+=1;
},
//绑定事件
addHandle:function(){
var that = this;
$("#"+this.moreNode.id).bind('click',function(){
//加载更多列表
that.createList(false);
});
}
}
//播放器控制面板
var Control = function(o){
this.setting = (typeof o === 'object')? o : {};
this.audio = this.setting.audio;
this.progressWrap = this.setting.progressWrap;
this.playModeNode = this.setting.playModeNode;
this.playBtn = this.setting.playBtn;
this.playTitle = this.setting.playTitle;
this.singerHead = this.setting.singerHead;
this.progress = this.setting.progress;
this.oWinObj = this.setting.oWinObj;
this.allTimeNode = this.setting.allTimeNode;
this.currentTimeNode = this.setting.currentTimeNode;
this.path = 'media/'; //歌曲路径(相对于html)
this.imgPath = 'data/'; //图片路径(相对于html)
this.init();
}
Control.prototype = {
//初始化
init:function(){
//播放控制
this.start = true;
//定时器
this.timer = null;
this.audio.src = null;
//可选播放模式
this.ModeData = [
{mode:'default',text:'顺序播放模式'},
{mode:'random',text:'随机播放模式'},
{mode:'single',text:'单曲循环模式'}
];
//默认播放模式
this.ModeIndex = 0;
this.playMode = this.ModeData[this.ModeIndex].mode;
},
//选择歌曲列表
selectList:function(_this,stack){
var allow = true;
var index = null;
this.oLi = _this;
this.oUl = _this.parentNode;
if(index == stack && !this.start ){
allow = false;
}
index = stack;
this.loadMusic();
if(allow){
this.goPlay();
}else{
this.goPause();
}
},
//上一首
prev:function(){
if(this.oLi.previousSibling!=null){
this.oLi = this.oLi.previousSibling;
this.loadMusic();
}else{
this.oWindow("已经是第一首了哦!");
}
this.goPlay();
},
//主控
mainControl:function(){
if(this.start){
this.goPlay();
}else{
this.goPause();
}
},
//下一首
next:function(){
if(this.oLi.nextSibling!=null){
this.oLi = this.oLi.nextSibling;
this.loadMusic();
}else{
this.oWindow("已经是最后一首了哦!")
}
this.goPlay();
},
//播放模式选择
selectMode:function(){
this.ModeIndex = (this.ModeIndex<(this.ModeData.length-1))?(this.ModeIndex+1):0;
this.playMode = this.ModeData[this.ModeIndex].mode;
this.oWindow(this.ModeData[this.ModeIndex].text);
this.playModeNode.attr("class","mode-"+this.playMode);
},
//播放进度选择
selectTime:function(event){
var moveTo = event.pageX - this.progressWrap.offset().left;
this.audio.currentTime = moveTo/parseInt(this.progressWrap.css("width"))*this.audio.duration;
this.progress.css("width",moveTo+"px");
},
//自动播放
autoPlay:function(){
//监听歌曲结束
var that = this;
this.audio.addEventListener('ended', function () {
if(typeof that.playMode==='string')
{ //播放模式判断
switch(that.playMode){
case 'default': that.oLi = (that.oLi.nextSibling!=null)?that.oLi.nextSibling:that.oUl.childNodes[0];
break;
case 'random': that.oLi = that.oUl.childNodes[Math.round(Math.random()*(that.oUl.childNodes.length-1))];
break;
case 'single': ;
default: ;
}
that.loadMusic();
that.goPlay();
}else{
that.oWindow("循环类型不符!");
}
},false);
},
//加载要播放的歌曲
loadMusic:function(){
$obj = $(this.oLi)
var song = $obj.find(".musicData").attr("value");
var pic = $obj.find(".musicData").attr("pic");
var title = $obj.find(".musicData").attr("title");
//this.singerHead.attr("src",this.imgPath + pic)
//this.audio.src = this.path + song +'.mp3';
this.singerHead.attr("src", pic)
this.audio.src = song ;
this.playTitle.html(title);
},
//-------------------------------------------------------------------------------------------------------------------
DjDowns:function(){$obj = $(this.oLi)
var song = $obj.find(".musicData").attr("jid");
var name= $obj.find(".musicData").attr("titlej");
if (song!==undefined) {
//location.href = '/jj_'+song+'.html';
javascript:setbg2('下载音乐',350,360,'/user/xzdjcs_'+song+'');
//document.cookie ="Playname="+ $obj.find(".musicData").attr("title");
}
},
//-------------------------------------------------------------------------------------------------------------------
//判断当前是否歌曲列表
songReady:function(){
if(!this.audio.src){
this.oWindow("请先选择歌曲!")
return false;
}else{
return true;
}
},
//转换为时间格式
timeDispose:function (number) {
var minute = parseInt(number / 60);
var second = parseInt(number % 60);
minute = minute >= 10 ? minute : "0" + minute;
second = second >= 10 ? second : "0" + second;
return minute + ":" + second;
},
//自定义提示框
oWindow:function(oText){
this.oWinObj.show();
this.oWinObj.html(oText);
var doc = document.documentElement;
var oWinX = (doc.clientWidth - this.oWinObj[0].offsetWidth)/2;
var oWinY = (doc.clientHeight - this.oWinObj[0].offsetHeight-50)/2;
this.oWinObj.css('left',oWinX+'px');
this.oWinObj.css('top',oWinY+'px');
var _this = this;
setTimeout(function(){_this.oWinObj.hide();},500)
},
//播放时间
oTime:function(){
if(this.audio.readyState >=4){
var currentProgress = Math.round(this.audio.currentTime/this.audio.duration*parseInt(this.progressWrap.css("width")));
this.progress.css("width",currentProgress+"px");
this.allTimeNode.html(this.timeDispose(this.audio.duration));
document.cookie ="Playsc="+ this.timeDispose(this.audio.duration);
this.currentTimeNode.html(this.timeDispose(this.audio.currentTime));
}
},
//播放
goPlay:function(){
if(this.songReady()){
this.audio.play();
var _this = this;
this.goPlayStyle();
this.timer = setInterval(function(){_this.oTime()},1)
this.start = false;
this.autoPlay();
}
},
//暂停
goPause:function(){
this.audio.pause();
this.goPauseStyle();
clearInterval(this.timer);
this.start = true;
},
//播放样式
goPlayStyle:function(){
var $oLiIndex = $(this.oLi);
$(".frmPause").removeClass("frmPause");
//$oLiIndex.find(".frmPlay").addClass("frmPause");
$oLiIndex.find(".frmJJ").addClass("frmPause");
this.playBtn.addClass("pause");
this.playBtn.removeClass("play");
},
//暂停样式
goPauseStyle:function(){
var $oLiIndex = $(this.oLi);
$(".frmPause").removeClass("frmPause");
this.playBtn.addClass("play");
this.playBtn.removeClass("pause");
}
}
function JJGMusic(){
var aa={};
//模块设置
var setting = {
newSong:{'target':'newSong','type':'1','firstCount':50,'Count':50},
songCharts:{'target':'newSong','type':'1','firstCount':10,'Count':10},
singer:{'target':'newSong','type':'1','firstCount':10,'Count':10},
radioStation:{'target':'newSong','type':'1','firstCount':10,'Count':10}
};
//默认加载模块
aa.newSong = new JJG(setting.newSong);
//模块初始化
$(".menu_tagList").children("li").bind('click',function(){
for(var i in setting){
if($(this).attr("id")==i){
if(typeof aa[i]==='undefined'){
aa[i] = new JJG(setting[i]);
}else{
aa[i].init();
}
}
}
$(".menu_hover").removeClass("menu_hover");
$(this).addClass("menu_hover");
})
}
//实例化控制台
var myControl = new Control({
audio : document.getElementById("myMusic"), //播放器
playModeNode : $("#modeButton"), //模式选择按钮
playBtn : $("#playButton"), //主控按钮
playTitle : $("#musicTitle"), //歌曲TITLE容器
singerHead : $("#singerHead"), //歌曲插图容器
progressWrap : $("#progressWrap"), //歌曲进度条容器
progress : $("#progress"), //歌曲进度条
oWinObj : $("#oWindow"), //警告窗容器
allTimeNode : $("#totleTime"), //当前时间容器
currentTimeNode : $("#currentTime") //当前时间容器
});
JJGMusic();