Re: Embed movie player (with process)



Hello

> 1)
> Simply start a movie player (e.g. totem for Linux and MediaPlayer for
> Windows) in new process. This is not embedded, but easy to implement.

I'm working something like this, but it's not so easy. The Windows don't 
have fork() or something like fork(), and the process system is not 
equivalent with the POSIX's system.

Try search in the mplayer mailing-lists. There are many examples.
I use the ::CreateProcess function, but in this case you must use HANDLE-s 
and no way to convert a HANDLE to FILE* or int. You can work also with the 
_spawn function family.

A very simple wrapper:
class Base_Process
{
public:
    Base_Process();
    ~Base_Process();
    bool is_started() const throw() { return m_started; }
protected:
    std::string read_line();
    bool send_command(const std::string&); //useful for mplayer slave mode
    bool run(const std::string& cmd);
private:
    bool m_started;
#ifdef WIN32
    HANDLE m_input,m_output
...
#else
    Pid m_parent;
    int pipe_child[2];
...
#endif
}; 

And you can use it like this:
class MyEmbendedWindow : public Base_Process, public Gtk::Widget
{
...
};

MyEmbendedWindow::~MyEmbendedWindow()
{
  if (is_started())
    send_command("quit\n");
}

void MyEmbendedWindow::on_realize()
{
  if (!ref_gdk_window_)
  {
    XID id = GDK_WINDOW_XWINDOW(ref_gdk_window_->gobj());
    std::string cmd("mplayer -quiet -slave -idle ");
    char num[38];
    sprintf(num,"-wid %d",id);
    cmd+=num;
    run(cmd);
  }
}
I am not sure in this. But you need the window id to run mplayer.

Use the ::ReadFile and the ::PeekNamedPipe to reading.
You can start at the Widget creation the mplayer with the -slave -quiet -idle
flags and it will start at the backround, and wait for instuctions.

Good luck,
khraath



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]