]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/MediaCtrl.py
6 #----------------------------------------------------------------------
8 class TestPanel(wx
.Panel
):
9 def __init__(self
, parent
, log
):
11 wx
.Panel
.__init
__(self
, parent
, -1,
12 style
=wx
.TAB_TRAVERSAL|wx
.CLIP_CHILDREN
)
14 # Create some controls
15 self
.mc
= wx
.media
.MediaCtrl(self
)
16 self
.mc
.SetMinSize((320,200))
18 btn1
= wx
.Button(self
, -1, "Load File")
19 self
.Bind(wx
.EVT_BUTTON
, self
.OnLoadFile
, btn1
)
21 btn2
= wx
.Button(self
, -1, "Load URL")
22 self
.Bind(wx
.EVT_BUTTON
, self
.OnLoadURI
, btn2
)
24 btn3
= wx
.Button(self
, -1, "Play")
25 self
.Bind(wx
.EVT_BUTTON
, self
.OnPlay
, btn3
)
27 btn4
= wx
.Button(self
, -1, "Pause")
28 self
.Bind(wx
.EVT_BUTTON
, self
.OnPause
, btn4
)
30 btn5
= wx
.Button(self
, -1, "Stop")
31 self
.Bind(wx
.EVT_BUTTON
, self
.OnStop
, btn5
)
34 sizer
= wx
.GridBagSizer(5,5)
35 sizer
.Add(self
.mc
, (1,1), span
=(5,1))#, flag=wx.EXPAND)
36 sizer
.Add(btn1
, (1,3))
37 sizer
.Add(btn2
, (2,3))
38 sizer
.Add(btn3
, (3,3))
39 sizer
.Add(btn4
, (4,3))
40 sizer
.Add(btn5
, (5,3))
44 def OnLoadFile(self
, evt
):
45 dlg
= wx
.FileDialog(self
, message
="Choose a media file",
46 defaultDir
=os
.getcwd(), defaultFile
="",
47 style
=wx
.OPEN | wx
.CHANGE_DIR
)
48 if dlg
.ShowModal() == wx
.ID_OK
:
50 if not self
.mc
.Load(path
):
51 wx
.MessageBox("Unable to load %s." % path
,
52 "ERROR: Unsupported format?",
53 wx
.ICON_ERROR | wx
.OK
)
55 self
.mc
.SetBestFittingSize()
56 self
.GetSizer().Layout()
60 def OnLoadURI(self
, evt
):
61 dlg
= wx
.TextEntryDialog(self
, "URL:", "Please enter the URL of a media file",
62 "http://www.mwscomp.com/movies/grail/tim-the-enchanter.avi")
63 if dlg
.ShowModal() == wx
.ID_OK
:
65 if not self
.mc
.LoadFromURI(url
):
66 wx
.MessageBox("Unable to load %s." % url
,
67 "ERROR", wx
.ICON_ERROR | wx
.OK
)
69 self
.mc
.SetBestFittingSize()
70 self
.GetSizer().Layout()
74 def OnPlay(self
, evt
):
77 def OnPause(self
, evt
):
80 def OnStop(self
, evt
):
86 #----------------------------------------------------------------------
88 def runTest(frame
, nb
, log
):
90 win
= TestPanel(nb
, log
)
92 except NotImplementedError:
93 from Main
import MessagePanel
94 win
= MessagePanel(nb
, 'wx.MediaCtrl is not available on this platform.',
95 'Sorry', wx
.ICON_WARNING
)
99 #----------------------------------------------------------------------
103 overview
= """<html><body>
104 <h2><center>wx.MediaCtrl</center></h2>
111 if __name__
== '__main__':
114 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])