User:scanff/Libwiiradio

From WiiBrew
< User:Scanff
Jump to: navigation, search

libwiiradio
Wiiradio img.png
General
Author(s)Scanff
TypeLibrary
Version1.00

Libwiiradio is a simple and easy to implement library you can add to your game or homebrew app that gives you the ability to playback internet radio.


Quickstart

There is an example of how to use LibWiiRadio included in the download.

Here's a list of the functions.

// play a stream
int LWR_Play(char*);

// stop playback
int LWR_Stop();

// return the current URL
char* LWR_GetUrl();

// return what's playing
char* LWR_GetCurrentTrack();

// return bitrate
int LWR_GetCurrentBitRate();

// return the volume
int LWR_GetVolume();

// set the volume
void LWR_SetVolume(int);

Here's a quick example.

char* tests[] = {   "http://205.188.215.225:8002",
                    "http://scfire-dtc-aa07.stream.aol.com:80/stream/1040",
                    "http://208.76.152.74:8000"
				};



int test_lib()
{
    printf("\n\n\n\nTest libWiiRadio, will test three streams!\n");

    for(int i = 0; i < 3;i++)
    {
        printf("Connecting to %s\n", tests[i]);


	LWR_SetVolume(40*(i+1));
        printf("setting volume %d\n", 40*(i+1));
		

        if(LWR_Play(tests[i]) < 0)
        {
            printf("ERROR!\n");
            LWR_Stop();
			continue;
        }

        usleep(2000000); // wait till the info is grabbed

        char *title = LWR_GetCurrentTrack();
        if (title) printf("current track = %s\n", title);

        int br = LWR_GetCurrentBitRate();
        if (br != -1) printf("current bitrate = %d\n", br);
		
	char* url = LWR_GetUrl();
	if (url) printf("current url = %s\n", url);
		
	int vol = LWR_GetVolume();
        if (vol != -1) printf("current volume = %d\n", vol);
		
        
	usleep(30000000); // play for a while
		

	printf("Stop Playback!\n");

        LWR_Stop();
    }

    printf("Test Done!\n");

    return 0;
}

Bugs & Suggestions

Soon

Update History

1.00 - Coming very soon

  • Initial release