Re: MPlayer's window embedding

Gianluigi Tiesi <[email protected]>
Newsgroups gmane.comp.video.mplayer.cygwin
Message-ID <[email protected]>
On Mon, Apr 30, 2007 at 02:47:51AM +0300, xofprog wrote:
> Hello,
> 
> How can I embed the window of mplayer into a window of a Win32 program 
> to create GUI for mplayer with an extended functionality?
> It's possible in any case?
> 
A very rude example using python and wxwindow, the real way to use it
is open a pipe with mplayer in slave mode, but anyway the example
shows how to tell mplayer to send video in a user window.

Bye

-- 
Gianluigi Tiesi <[email protected]>
EDP Project Leader
Netfarm S.r.l. - http://www.netfarm.it/
Free Software: http://oss.netfarm.it/

_______________________________________________
MPlayer-cygwin mailing list
[email protected]
http://lists.mplayerhq.hu/mailman/listinfo/mplayer-cygwin
mpovl.py (text/x-python, 1.3 KB)
from wx import PaintDC, Panel, Brush
from wx import SOLID
from wxPython.wx import wxPySimpleApp, wxFrame
from wxPython.wx import wxDEFAULT_FRAME_STYLE, wxNO_FULL_REPAINT_ON_RESIZE, wxID_ANY
from wxPython.wx import EVT_PAINT
from threading import Thread
from os import system

class Mplayer(Thread):
	def __init__(self, hwnd):
		Thread.__init__(self)
		self.hwnd = hwnd
	def run(self):
		cmd = 'mplayer.exe -quiet -colorkey 65793 -v -wid %s "colorbars.avs"' % self.hwnd
		print cmd
		system(cmd)

class OverlayPanel(Panel):
	def __init__(self, parent):
		Panel.__init__(self, parent, -1)
		self.Bind(EVT_PAINT, self.OnPaint)
	
	def OnPaint(self, evt):
		dc = PaintDC(self)
		dc.SetBackground(Brush('#010101', SOLID))
		dc.Clear()

class MainWindow(wxFrame):
	def __init__(self):
#		wxFrame.__init__(self, None, wxID_ANY, "Mplayer", size = (640, 360), style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
		wxFrame.__init__(self, None, wxID_ANY, "Mplayer", size = (640, 300), style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
		self.panel = OverlayPanel(self)
		self.panel.SetSize((-1, -1))
		self.Show(1)
		self.hwnd = '0x%08x' % self.panel.GetHandle()

					
if __name__ == '__main__':
	app = wxPySimpleApp()
	frame = MainWindow()
	mplayer = Mplayer(frame.hwnd)
	mplayer.start()
	app.MainLoop()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.