Re: [wxpython-users] wxMediaCtrl
by Timothy W. Grove other posts by this author
Jun 4 2009 5:12PM messages near this date
Re: [wxpython-users] wxMediaCtrl
|
Re: [wxpython-users] wxMediaCtrl
Dear Josiah,
This is quite an old posting, but I'm facing a similar problem to
Stuart. In your response below you mentioned specifically:
"Alternatively (what I would suggest) is to create a secondary thread
that uses wx.CallAfter() to call the wx.Timer event handler that you
would have written every 10 ms or so..."
Could you expand any further on how you would use wxCallAfter, perhaps
an example line of code? I think at some point today I was trying to use
wxCallLater() in a new thread, but it kept telling me that I needed to
call the timer from the main thread instead. I'm using wxPython 2.8
under Windows Vista, if that makes any difference!
Best regards,
Tim
Josiah Carlson wrote:
> On Thu, Aug 21, 2008 at 1:43 PM, Stuart Thiessen
> <thiessenstuart@[...].com> wrote:
>
> > I am working on a program where I want to be able to let a user select a
> > start and end point in a video using MediaCtrl.Tell() to find the actual
> > points. Then I want them to be able to click a button and just play that
> > clip. Finding those points is simple enough, but I am apparently not doing
> > it right to start it playing at the start point and tell it to pause or stop
> > at the end point.
> >
> > Any suggestions?
> >
> > Thanks,
> >
> > Stuart
> >
> > My code is as follows: (where self.startclip is the ms to start playing and
> > self.endclip is the ms to end playing. I am assuming as I look at my code,
> > that I need to do something with an Event handler somehow instead of what
> > I'm doing, but I'm not sure how I would do that.
> >
> > def OnPlayClip(self, evt):
> > self.mc.Seek(self.startclip)
> > self.mc.Play()
> > while self.mc.Tell() < self.endclip:
> > pass
> > self.mc.Stop()
> >
>
> That while loop is going to kill you, which is why things aren't
> working. Create a wx.Timer instance and have it signal an event every
> 100ms or so where you do your check to see if you should stop the
> video.
>
> Alternatively (what I would suggest) is to create a secondary thread
> that uses wx.CallAfter() to call the wx.Timer event handler that you
> would have written every 10 ms or so. Why? Because wx.Timer()
> instances are limited depending on the platform, have very limited
> precision, etc. I've found that just running a single thread in the
> background to handle scheduled events to be generally faster (a future
> release of PyPE uses this method to improve performance on OS X
> significantly).
>
> - Josiah
> _______________________________________________
> wxpython-users mailing list
> wxpython-users@[...].org
> http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
>
>
_______________________________________________
wxpython-users mailing list
wxpython-users@[...].org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Thread:
Stuart Thiessen
Josiah Carlson
Timothy W. Grove
Josiah Carlson
Stuart Thiessen
|