JS单曲调用百度mp3音乐播放器代码

 在网上找的单曲调用百度mp3音乐播放器的代码,改了改,文本框输入歌曲名,中文逗号,歌手名,回车就可以试听了。几点说明: 
  百度音乐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>
    


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值