From: Andy S. <laz...@gm...> - 2010-06-17 12:10:11
|
Hi all, I have add mplayer-client demo at "gtk/demo/embedded/MPlayer.hs" (darcs version) This is screenshot http://farm5.static.flickr.com/4007/4708981380_d59262b82d_b.jpg The principle is very simple: Because mplayer accept GDK_WINDOW_XID argument, so i get id (socketGetId) from GtkSocket, and pass socketId as argument of mplayer command. For control mplayer, we need enable "-slave" option, then we can pass "command\b" to mplayer's input handle. Example, i define "mplayerQuit" to quit mplayer process: mplayerQuit :: MPlayer -> IO () mplayerQuit MPlayer {mplayerHandle = mHandle} = do handle <- readTVarIO mHandle case handle of Just (inp, _, _, _) -> hPutStr inp "quit\n" Nothing -> return () My demo code just show how easy that use gtk2hs build client for other X11 program. Haven't include more control features for mplayer. For more features, please read "man" manual of mplayer. You can modified/improve it to build your own mplayer client with gtk2hs! :) You even can modified command code to make Emacs and Vim to embedded it with same principle. Enjoy! -- Andy |