Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   Wasabi Development (http://forums.winamp.com/forumdisplay.php?f=122)
-   -   Question on coding WACs (http://forums.winamp.com/showthread.php?t=76311)

Russ 17th February 2002 19:01

Question on coding WACs
 
Right, I've decided to have a play around with building some Winamp3 components, and I've got a bit stuck - this is about my first time coding C++, I've come from doing C on UNIX, and (*shudder*) VB.

OK, I've got the thing to compile and load (a struggle in itself ;)), and I've got integer options showing up in the prefs screen (i.e. _int something("Something", 1); ) , but I'm rather stuck on how to get boolean or string values to work there.

Secondly, can I get Winamp to call me back when the song changes, or do I have to poll it on a timer? (I haven't looked very hard with this)

-- Russ Garrett

soundsys 17th February 2002 20:39

the _int is one of the attribute types.
Look in attribute.h

Here are some known types :

INT = 'int',
STRING = 'str',
BOOL = 'bool',
FLOAT = 'flot'

R.N. aka soundsys

Russ 17th February 2002 21:14

Thanks, I had noticed that - maybe I'm being stupid, but I change:
_int something("Something", 1);
to:
_bool something("Something", TRUE);
and I get:

error C2146: syntax error : missing ';' before identifier 'something'
error C2501: '_bool' : missing storage-class or type specifiers
fatal error C1004: unexpected end of file found

on that line, similarly with str or flot.

-- Russ

Darkain 17th February 2002 22:15

make sure you got the right header included...

use this:
#include "../attribs/attribs.h"


this will automatically include all 4 types of attributes. after this, _bool SHOULD in theory work.


-=- Darkain Dragoon -=-

schweitn 17th February 2002 23:03

To answer your question on the Song Change callback... yes there is...

Here is how:

1. include "../studio/corecb.h"
2. Derive a class from CoreCallbackI
3. call api->core_addCallback in your class's constructor and api->core_delCallback in your class's destructor.
4. Override the functions of CoreCallbackI that interest you...

VERY IMPORTANT.... You need to look at CoreHandle to see exactly how your constructor and destructor have to work. You can find their definitions in common\corehandle.h and .cpp

SPECIAL HINT.... for when you are looking at CoreHandle, a token of 0 is the core identifier for the main playback engine in Winamp3.

Hope this helps.

Russ 18th February 2002 07:40

Aha... I'd been including attribute.h instead, and it wasn't complaining (should it?). And why does _int work where all the others don't?

Edit: It appears you need to use _string for strings, contrary to what it says in attribute.h.

-- Russ

Russ 18th February 2002 11:46

OK, I'm having a little trouble getting the callbacks to work - could you possibly post an example? I'm struggling a bit with all these classes :).

Russ 18th February 2002 12:36

Ain't it typical... got it working now :). Moved api->core_addCallback from the constructor to onCreate() and now it works. Makes sense now I think about it.. ;). Thanks everyone.

schweitn 18th February 2002 13:09

Quote:

Originally posted by RussGarrett
Ain't it typical... got it working now :). Moved api->core_addCallback from the constructor to onCreate() and now it works. Makes sense now I think about it.. ;). Thanks everyone.
It probably works in the constructor for me since the class that I have receiving the callback is not the main WAC class... its instead a child window... Just thought I'd mention so that you know that ANY class can receive those callbacks, not just the WACclient derived class. ;)

Russ 18th February 2002 13:21

Eek... ran into another problem which I thought would be easy... How the hell do I get info on the currently playing file? Do I have to use this metadb stuff (if so, how? :eek: ).

schweitn 18th February 2002 14:20

Thats pretty much the ONLY thing you can do right now involving song info since you can't traverse the playlist with the current SDK... try this:

api->core_getCurrent( ... )

This returns a const char* which has the playstring that can then be passed into the metadb.. I think.

Russ 18th February 2002 14:33

Ah, great - I'll have a play :)

Russ 18th February 2002 17:05

Hmmm... the metadb functions are in dire need of documentation... Could someone show me how to get the ID3 info from the playstring? ;)

schweitn 18th February 2002 17:49

Haven't messed around with this really... but I'll give you a few places to start...

Look in common\metatags.h to see the supported tags and their constants...

Then look at these functions in api:

int metadb_getMetaData(const char *playstring, const char *name,
char *data, int data_len, int data_type=0);

int metadb_getMetaDataType(const char *name);

The rest you should try figuring out. ;)

Russ 19th February 2002 13:22

Aaaaaaand it works (in the end) - I'll probably post it with the code in another thread as an example of a general plugin, so people can see how it all goes together :)

wa21guy 31st March 2002 07:55

Is it possible to have callbacks for song changes in Winamp 2.x? Also, if it is, can someone please port some code over to Visual Basic 6 for me? I need it bad cause I hate timers!

Ethan

schweitn 31st March 2002 18:21

Quote:

Originally posted by wa21guy
Is it possible to have callbacks for song changes in Winamp 2.x? Also, if it is, can someone please port some code over to Visual Basic 6 for me? I need it bad cause I hate timers!

Ethan

This is not about Winamp 2x, this is for Winamp 3x. Also, coding WACs can only be done in C++, not VB.


All times are GMT. The time now is 20:46.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.