What you probably want is the MPlayer sub- mode of operation , which makes it easy to transfer commands from another program. You can start MPlayer in this mode by providing it with a command line command -slavewhen it starts.
In this mode, MPlayer ignores its standard input bindings and instead accepts another dictionary of text commands that can be sent one at a time, separated by newlines. For a complete list of supported commands, run mplayer -input cmdlist.
Since you marked the question as Qt, I assume you are using C ++. Here's an example C program demonstrating how to use slave MPlayer mode:
#include <stdio.h>
#include <unistd.h>
int main()
{
FILE* pipe;
int i;
pipe = popen("mplayer -slave 'your_audio_file_here.mp3'", "w");
for (i = 0; i < 6; i++)
{
sleep(1);
fputs("pause\n", pipe);
fflush(pipe);
}
pclose(pipe);
return 0;
}
source
share