欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JavaScript實(shí)現(xiàn)帶播放列表的音樂播放器實(shí)例分享

 更新時(shí)間:2016年03月07日 17:05:50   作者:天天  
這篇文章主要介紹了JavaScript實(shí)現(xiàn)帶播放列表的音樂播放器實(shí)例分享,包括對(duì)播放完歌單之后沒有將要播放的歌曲的提示功能,需要的朋友可以參考下

代碼較最基礎(chǔ)的播放器實(shí)現(xiàn)增加了playlist,使用MakeList實(shí)現(xiàn)多首播放,有需要的可以直接使用:

<!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>Untitled Page</title>
</head>
<body style="font-family:Verdana; font-size:12px">


<script>
/*************************************************************
LovelyLife Player V1.0
Edited By LovelyLife
At 2006-09-16
All rights reservered
Code Start
Modify by http://www.tt419.cn/ 
*************************************************************/
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(status).innerHTML ='播放'
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))){
curId = 0
return 0
}
clearIt()
if(curId<0 || curId>arrPL.length){
alert("當(dāng)前沒有歌曲!,請(qǐng)查看播放列表!")
return false
}
nxtPlay()
}
if( s == 10 && arrPL.length >0 )
nxtPlay()
}
function nxtPlay(){
isStop = true
if(curId > arrPL.length - 1){
document.getElementById("songName").innerText = "沒有歌曲了,請(qǐng)選擇上一曲!"
document.getElementById(playid).URL = "NULL"
return false
}
curId++
clearIt()
setIt(curId)
PlayIt(curId)
}
function prePlay(){
isStop = true
if(curId<0){
document.getElementById("songName").innerText = "沒有歌曲了,請(qǐng)選擇下一曲!"
document.getElementById(playid).URL = "NULL"
return false
}
curId--
clearIt()
setIt(curId)
PlayIt(curId)
}
function PlayIt(cid){
if(curId<0 || curId>arrPL.length -1){
document.getElementById("songName").innerText = "當(dāng)前沒有歌曲!,請(qǐng)查看播放列表!"
return false
}
 url = arrPL[cid].url;
 
curId = cid
if(url == "None"){
document.getElementById("songName").innerText = "加載歌曲未找到!播放下一曲!"
nxtPlay()
return false
}
document.getElementById(playid).URL = url
document.getElementById("songName").innerText = arrPL[cid].name
}
function clearIt(){
if((arrPL.length - 1 <0) || selected < 0 || selected > arrPL.length){
 
return false
}
 
}
function setIt(tid){
if(tid<0 || tid>arrPL.length-1){
document.getElementById("songName").innerText = "當(dāng)前沒有歌曲!,請(qǐng)查看播放列表!"
return false
}
 
}
function InitPlay(songName,url,auto){
 
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>點(diǎn)播的歌曲: <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)
clearIt()
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 = "不循環(huán)"
isLoop = false
}else{
document.getElementById('sloop').innerText = "循環(huán)播放"
isLoop = true
}
}
/* Code End */
window.attachEvent('onload', function(){
  InitPlay("女人如煙[詞曲:穆真 演唱:魏佳藝]","http://happy369.com/yy/nrry.mp3", 1);
  playAndpauseIt();
  })
</script>
<div id=player style="width:70%"></div>

<script>
MakeList(1,"http://happy369.com/yy/nrry.mp3","111");
MakeList(2,"http://www.gxyx.net/sourcefile/0/0/2/2958.wma","222");
MakeList(3,"http://hz.98777.com/rm0402/q/258.rm","333");
MakeList(4,"http://www.gxyx.net/sourcefile/0/0/2/2958.wma","4444");
</script>
</body>
</html>

MakeList參數(shù):共3個(gè)參數(shù),第一個(gè)是ID,第二個(gè)參數(shù)是音樂的URL地址,第三個(gè)參數(shù)是歌曲的名稱。說明都寫在注釋里了,歡迎大家閱讀和參考。

相關(guān)文章

  • JS實(shí)現(xiàn)根據(jù)數(shù)組對(duì)象的某一屬性排序操作示例

    JS實(shí)現(xiàn)根據(jù)數(shù)組對(duì)象的某一屬性排序操作示例

    這篇文章主要介紹了JS實(shí)現(xiàn)根據(jù)數(shù)組對(duì)象的某一屬性排序操作,涉及javascript針對(duì)json數(shù)組的遍歷、比較、排序等相關(guān)操作技巧,需要的朋友可以參考下
    2019-01-01
  • JS使用iView的Dropdown實(shí)現(xiàn)一個(gè)右鍵菜單

    JS使用iView的Dropdown實(shí)現(xiàn)一個(gè)右鍵菜單

    這篇文章主要介紹了JS使用iView的Dropdown實(shí)現(xiàn)一個(gè)右鍵菜單功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-05-05
  • 淺談JavaScript事件綁定的常用方法及其優(yōu)缺點(diǎn)分析

    淺談JavaScript事件綁定的常用方法及其優(yōu)缺點(diǎn)分析

    下面小編就為大家?guī)硪黄獪\談JavaScript事件綁定的常用方法及其優(yōu)缺點(diǎn)分析。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-11-11
  • JS實(shí)現(xiàn)身份證輸入框的輸入效果

    JS實(shí)現(xiàn)身份證輸入框的輸入效果

    這篇文章主要介紹了JS實(shí)現(xiàn)身份證輸入框的輸入效果,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2017-08-08
  • 微信js-sdk地理位置接口用法示例

    微信js-sdk地理位置接口用法示例

    這篇文章主要介紹了微信js-sdk地理位置接口用法,結(jié)合實(shí)例形式分析了js-sdk地理位置接口的定義與簡(jiǎn)單使用方法,需要的朋友可以參考下
    2016-10-10
  • 淺談javascript的Array.prototype.slice.call

    淺談javascript的Array.prototype.slice.call

    發(fā)現(xiàn)大多人都用了Array.prototype.slice.call(argments,0),一直不明白這句是干什么的。而昨天溫習(xí)了slice()方法,再參考Function.call(thisArg[, arg1[, arg2[, ...]]]),還是不得而知(我腦筋轉(zhuǎn)得慢:|)。
    2015-08-08
  • 微信小程序上線發(fā)布流程圖文詳解

    微信小程序上線發(fā)布流程圖文詳解

    這篇文章主要介紹了微信小程序上線發(fā)布流程,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-05-05
  • 基于BootStrap的圖片輪播效果展示實(shí)例代碼

    基于BootStrap的圖片輪播效果展示實(shí)例代碼

    這篇文章主要介紹了基于BootStrap的圖片輪播效果展示實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下
    2016-05-05
  • js正則表達(dá)式replace替換變量方法

    js正則表達(dá)式replace替換變量方法

    這篇文章主要介紹了js正則表達(dá)式/replace替換變量方法 ,最近項(xiàng)目任務(wù)繁重,更新博客會(huì)較慢,不過有時(shí)間希望可以把自己的積累分享出來,需要的朋友可以參考下
    2016-05-05
  • javascript實(shí)現(xiàn)簡(jiǎn)易計(jì)算器

    javascript實(shí)現(xiàn)簡(jiǎn)易計(jì)算器

    這篇文章主要為大家詳細(xì)介紹了javascript實(shí)現(xiàn)簡(jiǎn)易計(jì)算器,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-02-02

最新評(píng)論