如何在JS中获取Shoutcast当前曲目标题和插图

Dan*_*Boy 1 javascript api audio html5 shoutcast

我正在尝试创建一个自定义的广播播放器,该播放器会自动更新当前流式音频的标题和插图。

Shoutcast确实有一个API,但是它只能使用其Dev ID,但是Shoutcast最近显然没有提供任何Dev ID。所以我需要另一个解决方法。

有一些PHP解决方案,但是由于我不了解该语言,所以无法找到他们的解决方案。请提供一些有关如何获取当前曲目标题,插图甚至艺术家姓名的示例或提示。

提前致谢

Kur*_*den 6

以下大喊页面为您提供:

Current song:     http://yourstream:port/currentsong?sid=#
Last 20 songs:    http://yourstream:port/played.html?sid#
Next songs:       http://yourstream:port/nextsongs?sid=#
Run Code Online (Sandbox Code Playgroud)

nextsongs?sid=#必须由提供流的播放器支持。sc_trans支持此功能。

一个小的ajax jQuery示例:

// Get current song
function NowPlaying(){
    $.ajax({
        url: "http://www.mofosounds.com:8000/currentsong?sid=#", 
        type: "GET",
        success: function(result) {
            $("#playing").html(result);
        }
    });
}

// Update every 5 seconds
setInterval(function(){
    NowPlaying();
}, 5000);
Run Code Online (Sandbox Code Playgroud)

注意:为了执行跨域Ajax请求,必须启用CORS。在本文中阅读有关CORS的更多信息