Can Someone Help Me With This?

cc333

Tinkerer
Dec 22, 2021
56
33
18
California, USA
OK, I'm running a little Internet Radio stream for my own enjoyment, and I made up a little web player for it that displays some metadata.

Anyway, the problem is that when there's only one stream running on my server, everything's under 'source' and the metadata routine works fine, but when the header is something like '0' – as is the case when there's more than one active stream on the server – it breaks because what it's looking for is no longer under 'source.'

For example, when the JSON is like this:
JSON:
icestats
    admin    "***"
    host    "***"
    location    "Nowhere"
    server_id    "Icecast 2.4.4"
    server_start    "Sat, 22 Aug 2026 13:23:01 -0700"
    server_start_iso8601    "2026-08-22T13:23:01-0700"
    source
        audio_info    "ice-bitrate=320;ice-channels=2;ice-samplerate=44100"
        bitrate    320
        genre    "various"
        ice-bitrate    320
        ice-channels    2
        ice-samplerate    44100
        listener_peak    1
        listeners    0
        listenurl    "***"
        server_description    "Unspecified description"
        server_name    "Unspecified name"
        server_type    "audio/mpeg"
        stream_start    "Sat, 22 Aug 2026 13:42:09 -0700"
        stream_start_iso8601    "2026-08-22T13:42:09-0700"
        title    "Nicolette Larson - Rio de Janeiro Blue - In The Nick Of Time"
        dummy    null
My webplayer's metadata grabbing routine works fine, but if it's like this:
JSON:
icestats    
    admin    "***"
    host    "***"
    location    "Nowhere"
    server_id    "Icecast 2.4.4"
    server_start    "Sat, 22 Aug 2026 13:23:01 -0700"
    server_start_iso8601    "2026-08-22T13:23:01-0700"
        source    
            0    
                audio_info    "ice-bitrate=320;ice-channels=2;ice-samplerate=44100"
                bitrate    320
                genre    "various"
                ice-bitrate    320
                ice-channels    2
                ice-samplerate    44100
                listener_peak    1
                listeners    0
                listenurl    "***"
                server_description    "Unspecified description"
                server_name    "Unspecified name"
                server_type    "audio/mpeg"
                stream_start    "Sat, 22 Aug 2026 13:42:09 -0700"
                stream_start_iso8601    "2026-08-22T13:42:09-0700"
                title    "James Taylor - Country Road - Sweet Baby James"
                dummy    null
            1    
                audio_info    "ice-bitrate=256;ice-channels=2;ice-samplerate=44100"
                bitrate    256
                genre    "Various"
                ice-bitrate    256
                ice-channels    2
                ice-samplerate    44100
                listener_peak    0
                listeners    0
                listenurl    "***"
                server_description    "Unspecified description"
                server_name    "Radio1610"
                server_type    "audio/aac"
                stream_start    "Sat, 22 Aug 2026 13:59:16 -0700"
                stream_start_iso8601    "2026-08-22T13:59:16-0700"
                title    "James Taylor - Country Road - Sweet Baby James"
                dummy    null
It doesn't work.

Here's the code for the metadata routine:
JavaScript:
function fetchCurrentlyPlaying ()
            {jQuery.get('***/status-json.xsl', {}, function (response)
                {$('.currently-playing-title').html(response.icestats.source['title']);
                    document.title = response.icestats.source['title'];});}

Any ideas? While I could use AI to try fixing it, I'd rather not (I'm old-fashioned... I like communicating with real humans), but if any of you want to plug it in to your model of choice and give it a try, feel free.

c
 
Last edited:

jibsaramnim

Tinkerer
Mar 16, 2024
40
27
18
South Korea
davejansen.com
Small caveat up front that I'm on my phone and may make a typo.

Technically it might be cleaner to check if `source` is an array and then pull from its first entry if it is, but it might just be enough to add a bit of OR logic and call it a day? Something along the lines of;

JavaScript:
document.title = response.icestats.source[0]['title'] || response.icestats.source['title'];

I'm not sure what browser environment you're targeting, so if something like the above throws warnings as errors, you could wrap the whole thing in a try/catch.

Would this work for your needs?
 
  • Like
Reactions: cc333

cc333

Tinkerer
Dec 22, 2021
56
33
18
California, USA
@jibsaramnim Hmm, it might. I'll give it a try and let you know!

For this I'm targeting any recent browser, which I guess means pretty much Firefox and Chrome?

As an aside, I've tested the stream itself, and it works on SoundJam MP on Mac OS 9, so this project is somewhat vintage related insomuch as I've bothered to test that it works :)

That said, if I can eventually make a web-accessible player similar to this one, but compatible with Mac OS 9-era browsers (Mozilla, Netscape and IE 4.x and 5.x), that would be neat.

c
 
  • Like
Reactions: jibsaramnim

cc333

Tinkerer
Dec 22, 2021
56
33
18
California, USA
OK, I added in the OR logic you suggested, and while it may not be the cleanest, it worked!

This thing could stand a rewrite once I learn more, so I don't care if it's a bit clunky at present.

For reference, here's what it looks like on Firefox ESR 140.12 (the name of my station is "Radio1610"):
Screen Shot 2026-08-22 at 6.50.56 PM.png

The big light blue square is supposed to be for album artwork, but there's no logic because I didn't know how to make it work. All it is is a placeholder.

c