]> git.saurik.com Git - wxWidgets.git/commitdiff
Some tweaks for the wxMediaCtrl and enhaced the demo a bit
authorRobin Dunn <robin@alldunn.com>
Wed, 8 Dec 2004 21:49:41 +0000 (21:49 +0000)
committerRobin Dunn <robin@alldunn.com>
Wed, 8 Dec 2004 21:49:41 +0000 (21:49 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30904 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/demo/MediaCtrl.py
wxPython/src/media.i

index 91455942998145ecae11dd969887a1796bcdb95e..1514e246b2e3178b87933e948ad35c509deb4b5c 100644 (file)
@@ -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()
index c3e549df9bea392a9876585d1e432c2b2cb69553..416efc9a5b79878d9e7f18b8d3db013055b030b8 100644 (file)
@@ -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();
 };