【原创】根据歌名获取在线播放地址和LRC文件内容

xiaoxiao2026-08-25  5

在前几天做在线听歌(http://ting.faqee.com/)的过程中,碰到了根据歌名获取播放地址和LRC文件内容的问题,今晚花了几个小时把接口整理了一下,给大家吧,做在线听歌时,少不了他们的,代码如下:

<!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>听歌</TITLE> <META http-equiv=Content-Type content="text/html; charset=UTF-8"> <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script> <script> $(function(){ $("#surl").bind("click",function(){ $("#surl").attr("disabled",true); var song = encodeURI($("#kw").val()); song = encodeURI(song); var str = "<ul>"; $.getJSON("http://www.faqee.com/crm/song?act=songurl&song="+song+"&jsoncallback=?", function(json){ $.each(json,function(i,n){ n = n+""; i = i+""; if(i!="res"){ var ss = "<li>待选:<a href=\"#\">"+n+"</a></li>"; str=str+ss; }else{ if(n == "0"){ alert("抱歉,搜索不到歌曲!"); $("#surl").attr("disabled",false); return; } } }); str = str+"</ul>"; $("#searchsesult").html(str); $("#surl").attr("disabled",false); }); }); $("#slrc").bind("click",function(){ $("#slrc").attr("disabled",true); var song = encodeURI($("#kw").val()); song = encodeURI(song); var str = ""; $.getJSON("http://www.faqee.com/crm/song?act=songlrc&song="+song+"&jsoncallback=?", function(json){ $.each(json,function(i,n){ n = n+""; i = i+""; if(i!="res"){ $("#searchsesult").html(n); $("#slrc").attr("disabled",false); return; }else{ if(n == "0"){ alert("抱歉,搜索不到歌词!"); $("#slrc").attr("disabled",false); return; } } }); }); }); }); </script> </head> <body> <p/><p/> <div style="clear:both;text-align:left;margin:0;padding:0;"> 搜索: <input type="text" id="kw" style="width:250px;" value="国家"/>&nbsp;&nbsp; <input type="button" value="搜索歌曲地址" id="surl" />&nbsp;&nbsp; <input type="button" value="搜索LRC歌词" id="slrc" /> <div id="searchsesult"></div> </div> </body> </html>

 

转载请注明原文地址: https://www.6miu.com/read-5051816.html

最新回复(0)