Url format exception

Sep 12, 2012 at 7:06 PM

I get Url exception at ShoutcastStreamInformation.cs line 158.

            if (headers.TryGetValue(ShoutcastStreamInformation.IcyUrl, out value))            {

this.Url = new Uri(value); // here value comes from the stream: 184.168.74.213:7001

    }

shoutcast stream : http://184.168.74.213:7001/; stream.mp3

Jan 17, 2014 at 9:40 AM
I had the same problem. It happens because the Stream URL: field is there but has an empty value. So no exception is thrown as the TryGetValue still finds the key, however as the value is null an exception is thrown when the URL gets created.

The fix is simple:-

if (headers.TryGetValue(ShoutcastStreamInformation.IcyUrl, out value))
        {
            if (!string.IsNullOrEmpty(value))
            {
                this.Url = new Uri(value);
            }
        }