Radio Player – Mount Point Fixes – Updated – 14/10/2016

Going to push another update later today for the website side of the player. This should hopefully fix all mount points, especially related to Icecast 2 streams (Didn’t need to have the “/;” appended to the stream). Only took a very simple piece of code, but would love any feedback for stations that don’t work with this fix applied.

public function getMountPoint ($StreamURL) {
        
    if (stristr($StreamURL, ".mp3")) {
        return $StreamURL;
    } else {
        $Headers = get_headers($StreamURL, 1);
        if (isset($Headers["Server"])) {
            if (is_array($Headers["Server"]) && stristr($Headers["Server"][1], "Icecast 2.3.3-kh8"))
            {
                // Assume the server type is returned too
                // 0 = Server Type
                // 1 = Streaming Software type
                return $StreamURL . "/;";
            } else if (stristr($Headers["Server"], "Icecast")) {
                return $StreamURL;
            }
        } else {
            return $StreamURL . "/;";
        }
    }
}

All you need to do is send the StreamURL directly from ShoutCast (Playlist file for example) and this should return the correct mount point for the stream (This is all based around only accepting MP3 format streams for reference) within the HTML5 audio tag.

If anyone was looking for a similar fix then that small piece of code should potentially resolve the issue, more so, how Icecast 2 streams won’t load correctly with “/;” on the end of a stream url.

Edit.
Update applied to the base player – All feedback is welcome, especially for any stations that don’t work.

Update – 14/10/2016 :
Applied another check for radionomy hosted stations that wasn’t streamed correctly and would return an array in array for the “Server” header. Radionomy seem to have a slightly different config running under Windows Server with Icecast 2.3.3-kh8. If you still don’t get playback on certain stations, 90% chance you’re geo blocked by the radio provider.

Updated the main code to display the changes.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.