在网上找的单曲调用百度mp3音乐播放器的代码,改了改,文本框输入歌曲名,中文逗号,歌手名,回车就可以试听了。几点说明:
百度音乐api 音乐文件地址,span,p,div,等都可以,ID 必须是songplay;
参数说明,第一个是歌曲名字,第二个是演唱者,最后一个如果为空则自动播放,不为空则手动播放。
百度音乐api 音乐文件地址,span,p,div,等都可以,ID 必须是songplay;
参数说明,第一个是歌曲名字,第二个是演唱者,最后一个如果为空则自动播放,不为空则手动播放。
参数间用中文逗号 , 分隔 ,点击按钮或者回车都可以播放。
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JS单曲调用百度mp3音乐播放器代码丨<a target=_blank href="http://www.ylxxhs.net/">石家庄化妆培训</a>|<a target=_blank href="http://www.caopingzhixiao.com/">草坪销售</a></title>
</head>
<body>
<input id="songInfo" type="text" value="" style="width:288px; font-size:16px; height:20px; line-height:20px; vertical-align:middle" οnkeydοwn="return SubmitKeyClick(this,event)" />
<button id="playGo" style="height:26px; line-height:26px; padding:0 10px; font-size:14px; vertical-align:middle">百度播放</button>
<br/><br/>
<span id="songplay">挪威的森林,伍佰</span>
<script type="text/javascript">
<!--
function play(name,artist,auto){
var qwert = '<div style="width:400px; height:77px; background:url([url]http://www.csrcode.cn/imagesforcode/201205/img.gif[/url]) no-repeat;"><embed style="width:300px; height:48px; margin:0px; padding:0px; float:left;" src="http://box.baidu.com/widget/flash/mbsong.swf?name='+name+'&artist='+artist+'&autoPlay='+auto+'" width="310" height="51" allowscriptaccess="never" allownetworking="internal" type="application/x-shockwave-flash" /></div>';
document.getElementById('songplay').innerHTML = qwert;
}
song = document.getElementById('songplay').innerHTML;
if(typeof(song) !='undefined' && song !=''){
d = song.split(',');
var a = '';
if(d[2] ='undefined'){a = 'true';}
if(d[2] !='undefined'){a = 'false';}
play(d[0],d[1],a);
}
function playSong(songVal){
if(typeof(songVal) !='undefined' && songVal !=''){
var d = songVal.split(',');
var a = '';
if(d[2] ='undefined'){a = 'true';}
if(d[2] !='undefined'){a = 'false';}
play(d[0],d[1],a);
}
}
var playBtn = document.getElementById("playGo");
playBtn.οnclick=function(){
playSong(document.getElementById("songInfo").value);
}
function SubmitKeyClick(obj, evt) {
evt = (evt) ? evt : ((window.event) ? window.event : "")
keyCode = evt.keyCode ? evt.keyCode : (evt.which ? evt.which : evt.charCode);
if (keyCode == 13) {
playSong(document.getElementById("songInfo").value);
}
}
-->
</script>
<pre>
//百度音乐api [url]http://box.baidu.com/widget/flash/mbsong.swf?name=[/url]泪桥&artist=伍佰&autoPlay=true
//span,p,div,等都可以,ID 必须是songplay
//参数说明,第一个是歌曲名字,第二个是演唱者,最后一个如果为空则自动播放,不为空则手动播放
//参数间用中文逗号 , 分隔 ,点击按钮或者回车都可以播放
</pre>
</body>
</html>
<br><br><hr>