Michele Orrù avatar Michele Orrù committed 2f3e2b4

Adding stop button

Comments (0)

Files changed (2)

player-example.py

                                 wx.Bitmap(self.ICONSPATH+"pause.png"))
         play  = wx.BitmapButton(ctrlpanel, -1,
                                 wx.Bitmap(self.ICONSPATH+"play.png"))
+        stop = wx.BitmapButton(ctrlpanel, -1,
+                                wx.Bitmap(self.ICONSPATH+"stop.png"))
         volume = wx.BitmapButton(ctrlpanel, -1,
                                  wx.Bitmap(self.ICONSPATH+'volume.png'))
         self.volslider = wx.Slider(ctrlpanel, -1, 0, 0, 100, size=(100, -1))
         # bind controls to events
         self.Bind(wx.EVT_BUTTON, self.OnPlay, play)
         self.Bind(wx.EVT_BUTTON, self.OnPause, pause)
+        self.Bind(wx.EVT_BUTTON, self.OnStop, stop)
         self.Bind(wx.EVT_BUTTON, self.OnToggleVolume, volume)
         self.Bind(wx.EVT_SLIDER, self.OnSetVolume, self.volslider)
         # Give a pretty layout to the controls
         # box2 contains some buttons and the volume controls
         box2.Add(pause)
         box2.Add(play, flag=wx.RIGHT, border=5)
+        box2.Add(stop)
         box2.Add((-1, -1), 1)
         box2.Add(volume)
         box2.Add(self.volslider, flag=wx.TOP | wx.LEFT, border=5)
         file.
         """
         # if a file is already running, then stop it.
-        if self.player:
-            self.player.stop()
-            self.timer.Stop()
+        self.OnStop(None)
 
         # Create a file dialog opened in the current home directory, where
         # you can display all kind of files, having as title "Choose a file".
         else:
             self.errorDialog("No movie loaded.")
 
+    def OnStop(self, evt):
+        """
+        Stop the player.
+        """
+        if self.player:
+            self.player.stop()
+            self.timer.Stop()
+
     def OnTimer(self, evt):
         """
         Update the time slider according to the current movie time.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.