标题:
百度mp3变成点歌器(附源码)
[打印本页]
作者:
ape发烧
时间:
2012-3-2 10:11
标题:
百度mp3变成点歌器(附源码)
本帖最后由 ape发烧 于 2012-3-2 10:13 编辑
复制源码粘贴到txt文本中存为html格式的文件即可本机浏览
出处:http://blog.sina.com.cn/s/blog_93ee1cc701010vlx.html
<!doctype html>
<html lang="zh">
<head>
<meta charset="utf-8">
<title>百度播放器点歌程序</title>
<style type="text/css">
h1 { text-shadow: 2px 2px 5px #333; text-align:center; }
img { border:0px; }
a { text-decoration: none;color:#0066cc; }
a:hover { color:#ff0000; }
textarea { width:100%; border:0px; height:60px;text-align:left; font-size:12px; color: #666; overflow:hidden;
display:none; }
#main { margin:auto; padding:8px; width: 800px; border:1px solid #bbb; box-shadow:3px 3px 3px #aaa; text-align:center;
}
</style>
</head>
<body>
<h1>百度播放器点歌程序</h1>
<div id="main">
<table width="750"><tr>
<td>
<div id="bdplayer"></div>
<form>
<h1><p><font color=red size=5pt>在下方输入歌曲名称和歌手名字即可播放试听了!</font></p></h1>
<p><label for="name">歌曲名称: </label><input size="40" id="name" name="name" value="" tabindex="1"
onfocus="this.select();" onmouseup="onmouseupFn(event);" onchange="check();" /></p>
<p><label for="artist">艺 术 家: </label><input size="40" id="artist" name="artist" value="" tabindex="2"
onfocus="this.select();" onmouseup="onmouseupFn(event);" /></p>
<p><input id="play" name="play" type="button" onclick="playnow();" value=" 开始播放 " tabindex="3"
disabled="false" /> <input type="button" id="change" name="change" value=" 换 一 首 " onclick="begin();" /> <input
type="button" id="show" name="show" value=" 获取代码 " onclick="show_code();" /></p>
</form>
</td>
</tr></table>
<textarea id="code" name="code"></textarea>
</div>
<script type="text/javascript">
function playnow(){
var name = trim(document.getElementByIdx_x('name').value);
var artist = trim(document.getElementByIdx_x('artist').value);
var h_name = name.replace(/ /g,"+");
var h_artist = artist.replace(/ /g,"+");
var add_msg = '<a href=javascript:play("' + h_name + '","' + h_artist + '")>' + name + '</a>';
play(name,artist);
var s_song = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");//保存点歌信息
s_song.open("POST","img/savesong.php",true);
s_song.setRequestHeader("Content-type","application/x-www-form-urlencoded");
s_song.send("name=" + name + "&artist=" +artist + "");
document.getElementByIdx_x('newsong').innerHTML = add_msg + "<br />" + document.getElementByIdx_x('newsong').innerHTML;
document.getElementByIdx_x('play').disabled = true;
}
function show_code(){
var obj = document.getElementByIdx_x('code');
var btn = document.getElementByIdx_x('show');
btn.value = btn.value == " 获取代码 " ? " 隐藏代码 " : " 获取代码 ";
obj.value = (document.getElementByIdx_x('bdplayer').innerHTML).replace(/&/g,"&") + "</embed>";
obj.style.display = obj.style.display == "block" ? "" : "block";
}
document.onkeydown = function(e){//回车事件
var e = e || window.event;
var keyCode = e.keyCode || e.which;
var oTarget = e.srcElement || e.target;
if(keyCode == 13){
var tabIndex = oTarget.tabIndex;
tabIndex++;
}
var oInput = document.getElementsByTagName_r("input");
for(var i =0;i < oInput.length;i++){
if(oInput[i].tabIndex == tabIndex){
oInput[i].focus();
}
}
}
function trim(str){//删除左右空格
if(str.length > 0){
if(str.charAt(0) == " ") str = str.substring(1,str.length);
if(str.charAt(str.length-1) == " ") str = str.substring(0,str.length-1);
if(str.charAt(0)== " " || str.charAt(str.length-1) == " ") return trim(str);
}
return str;
}
function onmouseupFn(eventTag){//阻止chrome鼠标单击默认事件
var event = eventTag||window.event;
event.preventDefault();
}
function play(s_name,a_name){
document.getElementByIdx_x('bdplayer').innerHTML = '<embed height="74" type="application/x-shockwave-flash" width="500"
src="http://box.baidu.com/widget/flash/song.swf?name=' + s_name + '&artist=' + a_name +'&autoPlay=true&loop=true"
wmode="opaque"></embed>';
}
function check(){
if(document.getElementByIdx_x('name').value != ""){
document.getElementByIdx_x('play').disabled= false;
}
}
function begin(){
var rand = Math.random();
var range = song.length - 1;
var idx = Math.round(rand * range);
play(song[idx][0],song[idx][1]);
}
window.onload = begin;
//程序原创制作: 黑马
//海天居论坛大头修改
var song = [
['逞强','萧亚轩'],
['枉凝眉','古琴'],
['伤不起','王麟'],
['大礼堂','侃侃'],
['归去来兮','侃侃'],
['十送红军','刀郎'],
['映山红','刀郎'],
['三套车','童丽'],
['三套车','黑鸭子'],
['玛依拉','女子十二乐坊'],
['自由','
女子十二乐坊'],
['离弦','常静'],
['童年','bandari'],
['呼吸','常静'],
['媚','常静'],
['最熟悉的陌生人','萧亚轩'],
['泥娃娃','儿歌'],
['升','常静'],
['香水有毒','胡杨林'],
['长城','beyond'],
['大地','beyond'],
['红楼梦','陈琳'],
['布拉格广场','蔡依林'],
['love love love','蔡依林'],
['父亲','筷子兄弟'],
['鲁冰花','甄妮'],
['星语心愿','张柏芝'],
['逐梦令','李玉刚'],
['小红帽','邓丽欣'],
['爱在草原','范海荣'],
['only time',' enya'],
['春野','班得瑞'],
['荷塘月色','凤凰
传奇'],
['十二种颜色','陈琳'],
['冷雨','陈琳'],
['月亮代表我的心','邓丽君'],
['知道不知道','卡洛儿'],
['风居住的街道','
矶村由纪子'],
['爱的供养','杨幂'],
['sexually healing','elize'],
['one by one','恩雅'],
['莎莉花园','enya'],
['wild
child','enya'],
['小河淌水','米线'],
['小河淌水','朱婧'],
['小河淌水','龚玥'],
['小河淌水','古筝'],
['香格里拉','朱婧'],
['美丽骏马','朱婧'],
['蝴蝶劫','朱婧'],
['蚂蚁','朱婧'],
['阿诗玛','朱婧'],
['信天游','龚玥'],
['狼','齐
秦'],
['琴伤','周杰伦'],
['浪人情歌','许茹芸'],
['草原香','庞龙'],
['飞蛾','羽泉'],
['采蘑菇的小姑娘','卓依婷']
];
</script>
</body>
</html>
复制代码
作者:
idc886
时间:
2012-3-2 21:37
楼主,有样站没。
贴出来大家点点,这样就更能吸引。
欢迎光临 免费国外空间,国外免费空间, (http://idc866.com/)
Powered by Discuz! 7.2