<!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: &quot;GET&quot;,
            dataType: &quot;json&quot;,
            success: function(response) {
                var result = &quot;&quot;;
                for (var i = 0; i &lt; response.length; i++) {
                    result += &quot;&lt;div&gt;&quot;;
                    result += &quot;&lt;h3&gt;&quot; + response[i].title + &quot;&lt;/h3&gt;&quot;;
                    result += &quot;&lt;p&gt;Artist: &quot; + response[i].artist + &quot;&lt;/p&gt;&quot;;
                    result += &quot;&lt;p&gt;Download Link: &lt;a href='&quot; + response[i].downloadLink + &quot;'&gt;Download&lt;/a&gt;&lt;/p&gt;&quot;;
                    result += &quot;&lt;audio controls&gt;&quot;;
                    result += &quot;&lt;source src='&quot; + response[i].audioLink + &quot;' type='audio/mpeg'&gt;&quot;;
                    result += &quot;&lt;/audio&gt;&quot;;
                    result += &quot;&lt;/div&gt;&quot;;
                }
                document.getElementById(&quot;searchResults&quot;).innerHTML = result;
            },
            error: function() {
                document.getElementById(&quot;searchResults&quot;).innerHTML = &quot;Error occurred while searching for music.&quot;;
            }
        });
    }
&lt;/script&gt;
</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>
在线音乐搜索播放下载HTML代码示例 - 使用网易云音乐API

原文地址: https://www.cveoy.top/t/topic/pdza 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录