From: Robin Dunn Date: Wed, 8 Dec 2004 21:49:41 +0000 (+0000) Subject: Some tweaks for the wxMediaCtrl and enhaced the demo a bit X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/95262b5fa5519e3d6ab848a04e86902e985a550a?ds=sidebyside Some tweaks for the wxMediaCtrl and enhaced the demo a bit git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30904 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/wxPython/demo/MediaCtrl.py b/wxPython/demo/MediaCtrl.py index 9145594299..1514e246b2 100644 --- a/wxPython/demo/MediaCtrl.py +++ b/wxPython/demo/MediaCtrl.py @@ -3,6 +3,8 @@ import wx import wx.media import os +from Main import opj + #---------------------------------------------------------------------- class TestPanel(wx.Panel): @@ -12,23 +14,27 @@ class TestPanel(wx.Panel): style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN) # Create some controls - self.mc = wx.media.MediaCtrl(self) - self.mc.SetMinSize((320,200)) + self.mc = wx.media.MediaCtrl(self, -1, opj("data/testmovie.mpg"), + style=wx.SIMPLE_BORDER) + self.mc.SetBackgroundColour("black") + #self.mc.SetMinSize((320,200)) + self.mc.Stop() btn1 = wx.Button(self, -1, "Load File") self.Bind(wx.EVT_BUTTON, self.OnLoadFile, btn1) - btn2 = wx.Button(self, -1, "Load URL") - self.Bind(wx.EVT_BUTTON, self.OnLoadURI, btn2) + btn2 = wx.Button(self, -1, "Play") + self.Bind(wx.EVT_BUTTON, self.OnPlay, btn2) - btn3 = wx.Button(self, -1, "Play") - self.Bind(wx.EVT_BUTTON, self.OnPlay, btn3) + btn3 = wx.Button(self, -1, "Pause") + self.Bind(wx.EVT_BUTTON, self.OnPause, btn3) - btn4 = wx.Button(self, -1, "Pause") - self.Bind(wx.EVT_BUTTON, self.OnPause, btn4) + btn4 = wx.Button(self, -1, "Stop") + self.Bind(wx.EVT_BUTTON, self.OnStop, btn4) + + btn5 = wx.ToggleButton(self, -1, "Loop") + self.Bind(wx.EVT_TOGGLEBUTTON, self.OnLoopToggle, btn5) - btn5 = wx.Button(self, -1, "Stop") - self.Bind(wx.EVT_BUTTON, self.OnStop, btn5) # setup the layout sizer = wx.GridBagSizer(5,5) @@ -48,8 +54,8 @@ class TestPanel(wx.Panel): if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() if not self.mc.Load(path): - wx.MessageBox("Unable to load %s." % path, - "ERROR: Unsupported format?", + wx.MessageBox("Unable to load %s: Unsupported format?" % path, + "ERROR", wx.ICON_ERROR | wx.OK) else: self.mc.SetBestFittingSize() @@ -57,19 +63,10 @@ class TestPanel(wx.Panel): dlg.Destroy() - def OnLoadURI(self, evt): - dlg = wx.TextEntryDialog(self, "URL:", "Please enter the URL of a media file", - "http://www.mwscomp.com/movies/grail/tim-the-enchanter.avi") - if dlg.ShowModal() == wx.ID_OK: - url = dlg.GetValue() - if not self.mc.LoadFromURI(url): - wx.MessageBox("Unable to load %s." % url, - "ERROR", wx.ICON_ERROR | wx.OK) - else: - self.mc.SetBestFittingSize() - self.GetSizer().Layout() - dlg.Destroy() - + def OnLoopToggle(self, evt): + btn = evt.GetEventObject() + self.mc.Loop(btn.GetValue()) + def OnPlay(self, evt): self.mc.Play() diff --git a/wxPython/src/media.i b/wxPython/src/media.i index c3e549df9b..416efc9a5b 100644 --- a/wxPython/src/media.i +++ b/wxPython/src/media.i @@ -179,7 +179,8 @@ public: %pythonAppend wxMediaCtrl() "" - wxMediaCtrl(wxWindow* parent, wxWindowID id=-1, + wxMediaCtrl(wxWindow* parent, + wxWindowID id=-1, const wxString& fileName = wxPyEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, @@ -192,7 +193,8 @@ public: %extend { %name(MediaCtrlFromURI) - wxMediaCtrl(wxWindow* parent, wxWindowID id=-1, + wxMediaCtrl(wxWindow* parent, + wxWindowID id=-1, const wxString& location=wxPyEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, @@ -205,7 +207,8 @@ public: pos, size, style, szBackend, validator, name); } - bool CreateFromURI(wxWindow* parent, wxWindowID id=-1, + bool CreateFromURI(wxWindow* parent, + wxWindowID id=-1, const wxString& location=wxPyEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, @@ -220,7 +223,8 @@ public: } - bool Create(wxWindow* parent, wxWindowID id=-1, + bool Create(wxWindow* parent, + wxWindowID id=-1, const wxString& fileName = wxPyEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, @@ -249,9 +253,9 @@ public: double GetPlaybackRate(); bool SetPlaybackRate(double dRate); - bool SetPosition(wxLongLong where); - wxLongLong GetPosition(); - wxLongLong GetDuration(); + %name(SetMediaPosition) bool SetPosition(wxLongLong where); + %name(GetMediaPosition) wxLongLong GetPosition(); + %name(GetMediaDuration) wxLongLong GetDuration(); };