1.支持连续播放, 只要每次调用makelist(id, url, name)就会按顺序生成播放列表
<script>
/*************************************************************
lovelylife player v1.0
edited by lovelylife
at 2006-09-16
all rights reservered
code start
*************************************************************/
var playid = "lovelylifeplayer"
var status = "status"
var curid,arrpl,selected
var isstop,isloop
arrpl = new array() //播放器列表
cur = 0
curid = 0
isstop = false
selected = 0
isloop = true
function songobj(id,url, name){
this.id = id
this.url = url
this.name = name
}
function playandpauseit(){
if(document.getelementbyid(status).innertext == '暂停'){
document.getelementbyid(playid).controls.pause()
document.getelementbyid(status).innerhtml ='播放'
else{ document.getelementbyid(status).innertext = '暂停'
document.getelementbyid(playid).controls.play()}
function stopit(){
isstop = true
document.getelementbyid(playid).controls.stop()
function showtimer(){
var cp=document.getelementbyid(playid).controls.currentposition
var cps=document.getelementbyid(playid).controls.currentpositionstring
var dur=document.getelementbyid(playid).currentmedia.duration;
var durs=document.getelementbyid(playid).currentmedia.durationstring;
var s = document.getelementbyid(playid).playstate
var o = document.getelementbyid(playid).openstate
if( s==2 || s==3)
document.getelementbyid('pos').innertext = " " + cps + "/" + durs + " "
else
document.getelementbyid('pos').innertext = " 00:00/" + durs + " "
if( s == 1 ){
if(isloop && (curid > (arrpl.length - 1))){
return 0
clearit()
if(curid<0 || curid>arrpl.length){
alert("当前没有歌曲!,请查看播放列表!")
return false
nxtplay()
if( s == 10 && arrpl.length >0 )
function nxtplay(){
if(curid > arrpl.length - 1){
document.getelementbyid("songname").innertext = "没有歌曲了,请选择上一曲!"
document.getelementbyid(playid).url = "null"
curid++
setit(curid)
playit(curid)
function preplay(){
if(curid<0){
document.getelementbyid("songname").innertext = "没有歌曲了,请选择下一曲!"
curid--
function playit(cid){
if(curid<0 || curid>arrpl.length -1){
document.getelementbyid("songname").innertext = "当前没有歌曲!,请查看播放列表!"
//var url = "url.asp?iid=" + arrpl[cid].id
//url = loadit(url)
url = arrpl.url
curid = cid
if(url == "none"){
document.getelementbyid("songname").innertext = "加载歌曲未找到!播放下一曲!"
document.getelementbyid(playid).url = url
document.getelementbyid("songname").innertext = arrpl[cid].name
function clearit(){
if((arrpl.length - 1 <0) || selected < 0 || selected > arrpl.length){
//document.getelementbyid("songname").innertext = "加载歌曲未找到!播放下一曲!"
var selectedindex = eval("td_" + selected)
selectedindex.style.border = ""
function setit(tid){
if(tid<0 || tid>arrpl.length-1){
var selectedindex = eval("td_" + tid)
selectedindex.style.border = "1px solid #f00"
selected = tid
function initplay(songname,url,auto){
//document.write("<div id=player style=/"width:70%/"></div>")
var strtemp = "<object classid=/"clsid:6bf52a52-394a-11d3-b153-00c04f79faa6/""
strtemp += " type=/"application/x-oleobject/" width=/"0/" height=/"0/" id=" + playid
strtemp += " style=/"position:relative; left:0px; top:0px; width:0px; height:0px;/">/n"
strtemp += " <param name=/"autostart/" value=/""+auto+"/">/n"
strtemp += " <param name=/"balance/" value=/"0/">/n"
strtemp += " <param name=/"currentposition/" value=/"0/">/n"
strtemp += " <param name=/"currentmarker/" value=/"0/">/n"
strtemp += " <param name=/"enablecontextmenu/" value=/"0/">/n"
strtemp += " <param name=/"enableerrordialogs/" value=/"0/">/n"
strtemp += " <param name=/"enabled/" value=/"-1/">/n"
strtemp += " <param name=/"fullscreen/" value=/"0/">/n"
strtemp += " <param name=/"invokeurls/" value=/"0/">/n"
strtemp += " <param name=/"mute/" value=/"0/">/n"
strtemp += " <param name=/"playcount/" value=/"1/">/n"
strtemp += " <param name=/"rate/" value=/"1/">/n"
strtemp += " <param name=/"uimode/" value=/"none/">/n"
strtemp += " <param name=/"volume/" value=/"100/">/n"
strtemp += " <param name=/"url/" value=/"" + url + "/">/n"
strtemp += "</object>/n<font class=highlight style=/"background-color: #eee;padding: 8px;height:30px;width:100%/">"
strtemp += "<b>点播的歌曲: <marquee width=30% speed=3><font color=red id=songname>" + songname + "</font></marquee>"
strtemp += " [<font id=pos></font>]"
strtemp += " [<font onclick=playandpauseit() style='cursor:hand;' id=" + status + ">播放</font>]"
strtemp += "[<font onclick=stopit() style='cursor:hand;'>停止</font>]"
if((arrpl.length - 2) >= 0){
strtemp += "[<font onclick=preplay() style='cursor:hand;'>上曲</font>]"
strtemp += "[<font onclick=nxtplay() style='cursor:hand;'>下曲</font>]"
strtemp += " </b>"
document.getelementbyid('player').innerhtml = strtemp
temptimer=setinterval('showtimer()',1000);
function playx(cur){
playit(cur)
setit(cur)
curid = cur
selected = cur
function makelist(id,url,name){
arrpl[cur] = new songobj(id,url, name)
cur++
function loopit(){
if(isloop){
document.getelementbyid('sloop').innertext = "不循环"
isloop = false
}else{
document.getelementbyid('sloop').innertext = "循环播放"
/* code end */
window.attachevent('onload', function(){initplay('女人如烟[词曲:穆真 演唱:魏佳艺]','http://happy369.com/yy/nrry.mp3', 0)})
</script>
<div id=player style="width:70%"></div>