Re: Embed movie player using mplayer - How to execute mplayer (fork?)
- From: "Chris Wilson" <christopher g wilson gmail com>
- To: "Paulo Flabiano Smorigo" <pfsmorigo gmail com>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: Embed movie player using mplayer - How to execute mplayer (fork?)
- Date: Mon, 18 Aug 2008 13:11:04 -0500
Sorry Paulo, I sent reply to one, first.
One quick gotcha is that argv contains a vector of all the command
options. These are typically separated by spaces when typed on the
command line. However, your example has the whole command as one
option.
So put the wid to a std::string, widstring, and
argv.push_back("mplayer");
argv.push_back("-quiet");
argv.push_back("-slave");
argv.push_back("-idle");
argv.push_back("-wid");
argv.push_back(widstring);
argv.push_back("/home/test.
avi");
Glib::spawn_async_with_pipes(std::string("/usr/bin"),argv,Glib::SpawnFlags(0));
Personally, I'm using fork combined with execlp():
int pid = fork();
if(pid == 0)
{
std::stringstream filecommand;
filecommand <<"file=\""<<filename<<"\"";
int returncode = execlp("mplayer","mplayer","-slave","-quiet","-idle","-input",filecommand.str().c_str(),"-wid",wid.c_str(),fileToPlay.c_str(),NULL);
if(returncode == -1)
perror("error initializing.\n");
else
std::cout <<"mplayer finished running."<<std::endl;
exit(0);
}
where filename is the name of my named pipe file serving to control mplayer. wid, fileToPlay are both std::strings.
On Mon, Aug 18, 2008 at 10:13 AM, Paulo Flabiano Smorigo
<pfsmorigo gmail com> wrote:
Hi again,
I put the function spawn in my program but he gives me a "No such file or directory" error. I check the file and the path is right.
The code:
void Player::play(int wid)
{ int in_fd, out_fd;
sprintf(command, "mplayer -quiet -slave -idle -wid %d /home/test.avi", wid);
std::vector<std::string> argv;
argv.push_back(command);
Glib::spawn_async_with_pipes("/usr/bin", argv, Glib::SpawnFlags(0), sigc::slot<void>(), NULL, &in_fd, &out_fd, NULL);
}The error:
(test:8804): glibmm-CRITICAL **:
unhandled exception (type Glib::Error) in signal handler:domain: g-exec-error-quark
code : 8what : Failed to execute child process "mplayer -quiet -slave -idle -wid 60817444 /home/test.avi" (No such file or directory)
Anybody know what I'm doing wrong?
Thanks in advance...
P.F.Smorigo
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]