功能还没完,播放列表还没能保存到数据库,估计很快就可以提供
不嫌弃的可以拿来用着先
功能完成后再来发布
使用方法:
1.下载附件,把lookgo_music(当然你可以改名)放到站点根目录
2.在需要添加播放器的页面把js文件引进来
<script language="JavaScript" src="lookgo_music/music.js"></script>
3.在合适的位置添加播放器
- <div class="box">
- <script language="JavaScript" src="lookgo_music/music.js"></script>
- <style type="text/css">
- .music_mian{
- width:390px;
- height:150px;
- font-size:12px; color:#666666;
- padding:0px;
- border:1px #ccc solid;
- overflow:hidden;
- }
- .music_mian_left{
- width:179px;
- height:150px;
- margin:0px;
- padding:0px;
- float:left;
- border-right:1px #ccc solid;
- overflow:hidden;
- }
- .music_mian_right{
- width:210px;
- height:150px;
- margin:0px;
- padding:0px;
- float:left;
- overflow:hidden;
- text-align:center;
- }
- .music_time{ width:200px; margin:0px; padding:0px; height:19px; border-bottom:1px #efefef dotted; padding:2px;}
- .music_info{ width:200px; height:90px; margin:0px; padding:2px;}
- .music_btn{ width:100%; height:40px; line-height:40px;; margin:0px; border-top:1px #efefef dotted; text-align:center;}
- .music_list{ width:210px; height:114px; text-align:center;}
- .obutton{ font-size:12px; margin:0px; padding:0px; margin-top:5px;}
- .music_input{padding:2px; text-align:center;}
- #music_url,#music_name{ border:1px #ccc dotted;}
- .music_list_info{width:210px; height:70px; background-color:#efefef; overflow-y:scroll; overflow-x:hidden; text-align:left;}
- .music_page_info{width:210px; height:17px; background-color:#efefef; overflow:hidden; text-align:right;}
- </style>
- <div class="music_mian">
- <div class="music_mian_left">
- <div class="music_time"> <span id="disp_time">00:00 | 00:00</span>
- <marquee behavior="scroll" width="100" height="12" scrollamount="2" scrolldelay="70">
- <span id="disp_scroll">如歌,放飞心情的旅行...</span>
- </marquee>
- </div>
- <div class="music_info">
- <div id="capText">放飞心情,旅行如歌...<br />
- 本站所有歌曲只供试听<br>
- 假如喜欢请购买正版</div>
- </div>
- <div class="music_btn"> <img id="btnPrev"> <img id="pauzt"> <img id="stopt"> <img id="playt"> <img id="btnNext"> </div>
- </div>
- <div class="music_mian_right">
- <div class="music_list">
- <div class="music_input"> 歌名:
- <input name="music_name" type="text" id="music_name" size="4" maxlength="20"/>
- 地址:
- <input name="music_url" type="text" id="music_url" size="4" maxlength="500"/>
- <input name="music_add" type="button" id="music_add" value="添加" onClick="addToMusicList(document.getElementById('music_url'),document.getElementById('music_name'));">
- </div>
- <div id="music_list_info" class="music_list_info"></div>
- <div id="music_page_info" class="music_page_info"></div>
- </div>
- <div class="music_btn"> <img id="pmode"> <img id="rept"> <img id="vdn"> <img id="vup"> <img id="vmute">
- <input name="save_music_list" type="button" id="save_music_list" value="保存" onClick="saveMusicList();">
- </div>
- </div>
- </div>
- <script language="javascript">
- document.body.onload = function(){initExobud();}
- mkList("http://music.lookgo.cn/helen.mp3","我的名字叫伊莲");
- mkList("http://music.lookgo.cn/qhc.mp3","青花瓷");
- mkList("http://music.lookgo.cn/piece_of_me.mp3","piece_of_me");
- mkList("http://music.lookgo.cn/ooh_ooh_baby.mp3","ooh_ooh_baby");
- LookGo.cn.timer = "disp_time"; //设置时间容器ID
- LookGo.cn.marquee = "disp_scroll"; //滚动信息容器ID
- LookGo.cn.capText = "capText"; //字幕
- LookGo.cn.musiclist = "music_list_info";
- LookGo.cn.pageList = "music_page_info";
- LookGo.cn.blnAutoStart = true; //自动开始播放
- LookGo.cn.blnRndPlay = true; //随机播放
- LookGo.cn.blnStatusBar = false; //在状态拦显示信息
- LookGo.cn.blnShowVolCtrl = true; //允许控制音量
- LookGo.cn.blnShowPlist = true; //允许查看播放列表
- LookGo.cn.blnUseSmi = false; //开起字幕功能
- LookGo.cn.blnLoopTrk = true; //循环播放
- LookGo.cnblnShowMmInfo = false; //弹出窗口显示歌曲信息
- LookGo.cn.prevt = ["lookgo_music/images/btn_prev_off.gif","lookgo_music/images/btn_prev_on.gif","btnPrev"]; //上一首按钮
- LookGo.cn.nextt = ["lookgo_music/images/btn_next_off.gif","lookgo_music/images/btn_next_on.gif","btnNext"]; //下一首按钮
- LookGo.cn.rept = ["lookgo_music/images/btn_rept_off.gif","lookgo_music/images/btn_rept_on.gif","rept"]; //切换是否重复播放目前的曲目
- LookGo.cn.pmode = ["lookgo_music/images/btn_rndmode_off.gif","lookgo_music/images/btn_rndmode_on.gif","pmode"]; //播放顺序(S=循序 R=随机)
- LookGo.cn.stopt = ["lookgo_music/images/btn_stop_off.gif","lookgo_music/images/btn_stop_on.gif","stopt"]; //停止
- LookGo.cn.pauzt = ["lookgo_music/images/btn_pauz_off.gif","lookgo_music/images/btn_pauz_on.gif","pauzt"]; //暂停
- LookGo.cn.scope = ["lookgo_music/images/btn_scope_off.gif","lookgo_music/images/btn_scope_on.gif","scope"];
- LookGo.cn.playt = ["lookgo_music/images/btn_play_off.gif","lookgo_music/images/btn_play_on.gif","playt"]; //播放
- LookGo.cn.vmute = ["lookgo_music/images/btn_voice_on.gif","lookgo_music/images/btn_voice_off.gif","vmute"]; //静音模式
- LookGo.cn.vdn = ["lookgo_music/images/btn_vdn.gif","lookgo_music/images/btn_vdn.gif","vdn"]; //减少音量
- LookGo.cn.vup = ["lookgo_music/images/btn_vup.gif","lookgo_music/images/btn_vup.gif","vup"]; //增大音量
- LookGo.cn.plist = ["lookgo_music/images/btn_plist.gif","","plist"]; //播放列表
- LookGo.cn.blnAutoProc = true; //是否自动连续播放
- LookGo.cn.blnElaps = true; //设定播放面板上所显示的时间长度,预设是以正常方式(Elapse)抑或倒数方式(Lapse)显示
- LookGo.cn.intDelay = 500; //设定播放每首曲目之间的延迟时间(Delay Time),单位是毫秒(msec)
- LookGo.cn.init(); //初始化播放器
- </script>
- <script type="text/javascript">
- function saveMusicList() {
- var list = "";
- ajaxresponse_music(list);
- }
- function ajaxresponse_music(data) {
- var x = new Ajax('HTML');
- x.get('lookgo_music/save.php', function(s){
- var msg = trim(s);
- if(msg == 'System:ok_save') {
- alert("保存成功!");
- } else if(msg== 'System:no_login') {
- alert("请先登陆!");
- }
- });
- }
- function trim(str) {
- return str.replace(/^\s*(.*?)[\s\n]*$/g, '$1');
- }
- </script>
- </div>
复制代码 js代码还还有些乱所以混淆了一下,整理好了再公开,
按钮的调用已经很灵活了,只要注册一下就可以了,可以是图片也可以是input
LookGo.cn.playt = ["lookgo_music/images/btn_play_off.gif","lookgo_music/images/btn_play_on.gif","playt"]; //播放
LookGo.cn.playt = [图片1,图片2,按钮id];
放在哪里都可以,
不要的按钮可以不理会
备注: 代码是在前人的基础上整理的!
[ 本帖最后由 cnbloke 于 2008-8-31 18:49 编辑 ] |