最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to get Shoutcast current track title and artwork in JS - Stack Overflow

programmeradmin3浏览0评论

I am trying to create a customised radio player, that updates itself automatically about the title and artwork of the current streaming audio.

Shoutcast does have an API but it is only working with its Dev ID but Shoutcast recently does not provide any Dev ID apparently. So I need another workaround.

There are some PHP solution, but since I do not know the language I could not find out their solution. Could please provide some examples or hints about how to get the current track title, artwork, even possibly the artists name.

Thanks in advance

I am trying to create a customised radio player, that updates itself automatically about the title and artwork of the current streaming audio.

Shoutcast does have an API but it is only working with its Dev ID but Shoutcast recently does not provide any Dev ID apparently. So I need another workaround.

There are some PHP solution, but since I do not know the language I could not find out their solution. Could please provide some examples or hints about how to get the current track title, artwork, even possibly the artists name.

Thanks in advance

Share Improve this question edited Apr 9, 2018 at 20:34 DannyBoy asked Apr 5, 2017 at 14:42 DannyBoyDannyBoy 4441 gold badge6 silver badges23 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 12

The following shoutcast pages give you:

Current song:     http://yourstream:port/currentsong?sid=#
Last 20 songs:    http://yourstream:port/played.html?sid#
Next songs:       http://yourstream:port/nextsongs?sid=#

nextsongs?sid=# must be supported by the player which feeds the stream. sc_trans supports this feature.

A small ajax jQuery example:

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

// Update every 5 seconds
setInterval(function(){
    NowPlaying();
}, 5000);

Note: In order to do Cross domain ajax requests, CORS must be enabled. Read more about CORS in this article

without CORS

songName.php

$songName = file_get_contents('http://yourip:port/currentsong?sid=#');
echo $songName;

change function

// Get current song
function NowPlaying(){
    $.ajax({
        url: "songName.php", 
        type: "GET",
        success: function(result) {
            $("#playing").html(result);
        }
    });
}
发布评论

评论列表(0)

  1. 暂无评论