在线音乐搜索播放下载HTML代码示例 - 使用网易云音乐API
<!DOCTYPE html>
<html>
<head>
<title>在线音乐搜索播放下载</title>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>
function searchMusic() {
var input = document.getElementById("searchInput").value;
var url = "https://dataiqs.com/api/netease/music/?type=songid&id=" + input;
<pre><code> $.ajax({
url: url,
type: "GET",
dataType: "json",
success: function(response) {
var result = "";
for (var i = 0; i < response.length; i++) {
result += "<div>";
result += "<h3>" + response[i].title + "</h3>";
result += "<p>Artist: " + response[i].artist + "</p>";
result += "<p>Download Link: <a href='" + response[i].downloadLink + "'>Download</a></p>";
result += "<audio controls>";
result += "<source src='" + response[i].audioLink + "' type='audio/mpeg'>";
result += "</audio>";
result += "</div>";
}
document.getElementById("searchResults").innerHTML = result;
},
error: function() {
document.getElementById("searchResults").innerHTML = "Error occurred while searching for music.";
}
});
}
</script>
</code></pre>
</head>
<body>
<h1>在线音乐搜索播放下载</h1>
<input type="text" id="searchInput" placeholder="Enter artist or song name">
<button onclick="searchMusic()">Search</button>
<div id="searchResults"></div>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/pdza 著作权归作者所有。请勿转载和采集!