Radio

GGSharp supports Gadu Radio or Open.FM. It is able to login and get stream address.

How to get the stream?

using GGSharp;
///(...)
GGRadio radio = new GGRadio();
radio.ResponseReceived += new GGRadio.ResponseReceivedDelegate(radio_ResponseReceived);
radio.Login(666, "secret", "gr-lb-1.gaduradio.pl", 29);
///(...)
void radio_ResponseReceived(object sender, GGSharp.Radio.RDSResponseBase response)
{
    if (response.Type == GGSharp.Radio.ResponseType.Stream)
    {
        GGSharp.Radio.StreamResponse streamResponse = (GGSharp.Radio.StreamResponse)response;
        PlayMusicFromUrlStream(streamResponse.StreamAddress);
        ///StreamAddress is similar to: http://666:Z1Hd4jUxbE@gr-grr-13.gaduradio.pl:80/29
    }
}

How to get channel list?

It is available here http://static.gaduradio.pl/stations/2008070201.xml
You can access it this way:
radio.Channels.BeginRead("http://static.gaduradio.pl/stations/2008070201.xml", new AsyncCallback(channelsLoaded), null);
///(...)
void channelsLoaded(IAsyncResult result)
{
    foreach (GGSharp.Radio.XML.Channel channel in radio.Channels)
    {
        ///do sth with channels
    }
}
Or you can let the library autoload it for you. To do this you must leave GGRadio.AutoUpdateChannels set to true and just login to any station. The server will detect that you have an older version of channel list and will give us url to newer one.
radio.Channels.Loaded += new EventHandler(Channels_Loaded);
radio.Login(666, "secret", "gr-lb-1.gaduradio.pl", 29);
///(...)
void Channels_Loaded(object sender, EventArgs e)
{
    foreach (GGSharp.Radio.XML.Channel channel in radio.Channels)
    {
        ///do sth with channels
    }
}

Last edited Feb 1, 2009 at 6:11 PM by dra9ula, version 1

Comments

No comments yet.