[vlc-devel] Proper way to wait for VLC remote interface messages...
Jean-Paul Saman
jpsaman at videolan.org
Mon Mar 12 11:31:42 CET 2012
Hi,
On Wed, Feb 29, 2012 at 7:55 PM, Peter Tap <ptrtap at yahoo.com> wrote:
>
> Folks,
>
> In my Java application, I connect to VLC remote interface via socket, send
> the request (such as play, pause, etc.) and wait for the response. The way I
> am waiting for the response is shown in the following code:
Maybe this helps. It is a routine that sends one command and tries to
wait for its response from the rc-interface over a socket. I have used
it successfully in the past.
void vlc_rc( int fd, int repeat, char *cmd, size_t len, unsigned long sleep )
{
int i;
int result = 0;
char buff[255];
for( i=0; i<repeat; i++)
{
write( fd, cmd, len );
write( fd, NL, 2 );
usleep( sleep );
do {
memset( &buff[0], 0, 255);
result = read( fd, &buff[0], 255 );
buff[254] = '\0';
printf( "[%d] %s", i, &buff[0] );
} while( result > 0 );
}
printf( "DONE\r\n" );
}
Kind regards,
Jean-Paul Saman
More information about the vlc-devel
mailing list