User:scanff/Libwiiradio

From WiiBrew
Jump to navigation Jump to 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);

/* 
  Set the audio buffer size - default is 2MB which works well.
  This must be called before LWR_Play or it has no effect!
*/
int LWR_SetBufferSize(unsigned long);



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;
}

Linking

An example of linking Libwiiradio in your make file.

LIBS := -lwiiradio -lmad -lasnd -lbte -logc -lm


Bugs & Suggestions

I'm unsure how this lib would work with other sound libraries being used on Wii. If you are interested in testing and giving feedback I'd really appreciate it.

Please report to the main WiiRadio repository - http://code.google.com/p/wiiradio/issues/list

Update History

1.00 - Coming very soon

  • Initial release