[Alsaplayer-devel]remote control

Andy Lo A Foe andy@alsaplayer.org
Wed, 13 Feb 2002 19:20:13 +0100


On Wed, Feb 13, 2002 at 05:28:34PM +0100, CK wrote:

> I played a little bit with the client.c turned it into a pd external to
> remote control alsaplayer and wanted to add a setposition function to
> it.Again I'm stuck finding the actual functions (methods ?) responsible
> for positioning if anyone could just tell me where they are it would
> probably save me a lot of src wading/greping and the resulting head-
> ache.

Heh, it's not implemented yet :-)

I completely redesigned the socket interface last night. I still have
some issues. I'd like some feedback from everyone. The interface looks
like this:

typedef enum  {
        AP_DO_PLAY = 0x1,
        AP_DO_STOP,
        AP_DO_NEXT,
        AP_DO_PREV,
        AP_DO_PAUSE,
        AP_GET_FLOAT_PING,
        AP_SET_FLOAT_VOLUME,
        AP_GET_FLOAT_VOLUME,
        AP_SET_FLOAT_SPEED,
        AP_GET_FLOAT_SPEED,
        AP_GET_STRING_SESSION_NAME,
        AP_GET_STRING_SONG_NAME,
        AP_GET_INT_SONG_LENGTH,
        AP_GET_INT_CURRENT_TIME,
        AP_SET_INT_POS,
        AP_GET_INT_POS
				etc...
} ap_cmd_t;

int ap_connect_session(int session);
int ap_do(int session, ap_cmd_t cmd);
int ap_get_int(int session, ap_cmd_t cmd);
int ap_set_int(int session ,ap_cmd_t cmd, int val);
float ap_get_float(int session, ap_cmd_t cmd);
int ap_set_float(int session, ap_cmd_t cmd, float val);
int ap_get_string(int session, ap_cmd_t cmd, char *str);
int ap_set_string(int session, ap_cmd_t cmd, char *str);

----------------------------------------

So you first connect to a specific AlsaPlayer session with
ap_connect_session(...) (this function will probably take a string value
i.e. AlsaPlayer sessions will have user friendly string
identifications). With the session_id in hand you can call the rest of
the functions:

// Set speed to 200%
ap_set_float(session_id, AP_SET_FLOAT_SPEED, 2.0)

// Go to the next song
ap_do(session_id, AP_DO_NEXT);

// Get the current position in hundreths of seconds
pos = ap_get_int(session_id, AP_GET_INT_POS)

// Set the position of the song to 1min 30sec (90 seconds)
ap_set_int(session_id, AP_SET_INT_POS, 90 * 100);


This is the interface I propose, and have implemented for now. The idea
is to create binding for other languages too and I'm not sure the
current code will translate nicely to something other than C.

Keep in mind that most of the commands are not implemented yet, if you
feel like tackling some of them, or if you anticipate needing new
commands, please let me know (or send a patch ;-)

I will be implementing some more commands tonight, particularly the
string based ones.

Andy