[MPlayer-dev-eng] Slave mode and pipes
murban
murban at houston.rr.com
Wed May 22 02:50:01 CEST 2002
I have been thinking about writing a front-end for mplayer, so I've
experimented with a very simple program. Unfortunately, I can't get mplayer
to respond to the commands that I send to its standard input.
The program below I adapted from the GNU glibc manual documenting the use of
pipes and popen(). It should spawn a copy of mplayer in slave mode, wait 10
seconds, cause mplayer to quit and print a message to that effect for the
user, wait another 5 seconds, and stop. The program does start mplayer, but
it is not able to get mplayer to respond to commands.
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *stream;
int i;
stream = popen("mplayer -slave /tmp/myvid.mpg", "w");
if (stream == NULL)
{
fprintf(stderr, "Failure starting mplayer\n");
return EXIT_FAILURE;
}
sleep(10);
fprintf(stream, "quit\n");
printf("Stopping\n");
sleep(5);
if (pclose(stream) != 0) {
fprintf(stderr, "Error closing mplayer\n");
}
return EXIT_SUCCESS;
}
More information about the MPlayer-dev-eng
mailing list