在自己的网页中嵌入百度音乐盒
选择播放自己的音乐
完整代码如下:
my music
body{
margin:0;
padding: 0;
}
.p{
font-size: 20px;
font-family: "Times New Roman";
}
.center{
width: 500px;
height: 300px;
margin:20px 0 0 100px;
float:left;
}
请输入格式为“后来,刘若英”
百度播放
//初始化播放默认音乐
song = document.getElementById('songplay').value;
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);
}
var playBtn = document.getElementById("playGo");
playBtn.οnclick=function(){
playSong(document.getElementById("songInfo").value);
}
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);
}
}
function play(name,artist,auto){
var qwert = '
document.getElementById('songplay').innerHTML = qwert;
}
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);
}
}