[MPlayer-users] Can't get most commands to work in slave mode

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Aug 28 21:12:06 CEST 2008


On Thu, Aug 28, 2008 at 11:33:25AM -0700, Chuck Stein wrote:
> I forgot to mention:
> Sadly, this is on Windows.
> Also when I follow directions to try slave mode on a console, the console accepts no typed in commands.

That is due to the way the console works on Windows, AFAICT it is not
automatically connected to fd 0.
You could try searching in mplayer.c for the lines
> if(slave_mode)
>   mp_input_add_cmd_fd(0,USE_SELECT,MP_INPUT_SLAVE_CMD_FUNC,NULL);

And replace the "0" by "fileno(GetStdHandle(STD_INPUT_HANDLE))".
Apart from that, smplayer manages to use the slave mode without any
hacks.

> I am attempting to use mplayer from a C++ application.  I start it up in slave mode but I cannot get 'pause', 'stop', 'vo_fullscreen', or 'seek' to work.  I do have communication, as 'vo_ontop', and 'speed' do work.  I am using mplayer from the MPlayer-1.0rc2 download.  Here is my code:

rc2 is a bit old ("related projects" has newer builds).

>     char cmd[250];
>     sprintf(cmd, "C:\\dev\\MPlayer-1.0rc2\\mplayer -noborder -vo directx -slave -geometry 600:350 %s", movie_path);
>     if((mplayerPipe = popen(cmd, "w")) == NULL)
>         PostUserMessage("ERROR: failed to run command: %s\n", cmd);
> ...
> ...
>             fputs("quit\n", mplayerPipe);  // does not work
>             fflush(mplayerPipe); 
>             fputs("stop\n", mplayerPipe);  // does not work
>             fflush(mplayerPipe); 
>             fputs("pause\n", mplayerPipe);  // does not work
>             fflush(mplayerPipe); 
>             fputs("vo_fullscreen\n", mplayerPipe);   // does not work
>             fflush(mplayerPipe); 
>             fputs("vo_ontop 1\n", mplayerPipe);   // works!
>             fflush(mplayerPipe); 
> 
> I am testing this by stepping through the code.  Also, The documentation says the player does not take keyboard commands in slave mode, but I notice that it does.

More precisely the manual says:
> Instead of  intercepting  key‐
> board events, MPlayer will read commands separated by a newline (\n) from stdin.

Not that this talks only about stdin, not about anything it receives via
key-presses in a window, nor anything received via the console (which,
as said above, on windows to my knowledge is not the same as either
stdin or fd 0 - though on thinking more about it, compiling with
the -mwindows compiler flags might completely change it. Well, only
thing I remember for sure is that it is a complete mess.).

Greetings,
Reimar Döffinger



More information about the MPlayer-users mailing list