on load event and play in mediactrl

Hello!

I am trying to make MediaCtrl using Windows media player to automaticaly start playing the video.
According to google I have to use EVT_MEDIA_LOADED event to start Play(), but it doesn't work.
I found out that the even event isn't detected.

I am using wxPython-2.8.9.1 and python-2.5.2

Any ideas what might be wrong?

Boštjan

I have an app which uses this event, and it seems to work as expected
on Win2K and XP, but fail on Vista. I haven't asked about it here,
because none of my current users is on Vista. Perhaps Robin knows what
is going on.

···

2008/10/7 Boštjan Jerko <mlist@japina.eu>:

Hello!

I am trying to make MediaCtrl using Windows media player to automaticaly
start playing the video.
According to google I have to use EVT_MEDIA_LOADED event to start Play(),
but it doesn't work.
I found out that the even event isn't detected.

I am using wxPython-2.8.9.1 and python-2.5.2

Any ideas what might be wrong?

--
Best Regards,
Michael Moriarity

FWIW, EVT_MEDIA_LOADED appears to work fine on Vista (and elsewhere) using
wxPython-2.8.7.1-unicode under Python 2.4.4. Or at least my app works on
Vista, even functions that should be dependent upon EVT_MEDIA_LOADED. If
you need me to double-check, I can, but I don't actually have Python or
wxPython loaded on the Vista computer.

David

···

2008/10/7 Boštjan Jerko <mlist@japina.eu>:
> Hello!
>
> I am trying to make MediaCtrl using Windows media player to
> automaticaly start playing the video. According to google I have to
> use EVT_MEDIA_LOADED event to start Play(), but it doesn't work.
> I found out that the even event isn't detected.
>
> I am using wxPython-2.8.9.1 and python-2.5.2
>
>
> Any ideas what might be wrong?

I have an app which uses this event, and it seems to work as
expected on Win2K and XP, but fail on Vista. I haven't asked
about it here, because none of my current users is on Vista.
Perhaps Robin knows what is going on.

Thanks for the feedback, David. Please don't go to any trouble over
it. I had one person, not a regular user, try to run the py2exe
version of my app, which had worked for others, and it failed for him.
Using compiled debugging versions, I was able to determine that the
problem was that this event handler was not being called. I merely
hypothesized that Vista might be the problem, but based on your
evidence, it is probably some other oddity about his setup. Thanks
again.

···

2008/10/8 David Woods <dwoods@wcer.wisc.edu>:

FWIW, EVT_MEDIA_LOADED appears to work fine on Vista (and elsewhere) using
wxPython-2.8.7.1-unicode under Python 2.4.4. Or at least my app works on
Vista, even functions that should be dependent upon EVT_MEDIA_LOADED. If
you need me to double-check, I can, but I don't actually have Python or
wxPython loaded on the Vista computer.

--
Best Regards,
Michael Moriarity

Here is my test program (and it doesn't work). Even event is not detected:

class DemoFrame(wx.Frame):
  def __init__(self,parent,id):
    wx.Frame.__init__(self,parent,id)
    self.mp = wx.media.MediaCtrl(self, size=wx.Size(512,384))
    self.mp.ShowPlayerControls(flags=wx.media.MEDIACTRLPLAYERCONTROLS_STEP)
    self.mp.Load("./uvod.mpg")
    self.Bind(wx.media.EVT_MEDIA_LOADED,self.OnPlay)

  def OnPlay(self,event):
    print "playing"
    if self.mpState == mpPLAYING:
      self.mp.Pause()
      self.mpState = mpPAUSED
      self.Msg('Paused: %s' % self.ActiveFile)
    else:
      self.slider.SetMax(self.mp.Length())
      self.mp.Play()
      self.mpState = mpPLAYING
      self.Msg('Playing %s' % self.ActiveFile)

app = wx.PySimpleApp()
frame=DemoFrame(parent=None,id=-1)

frame.Show()
app.MainLoop()

Any ideas?

Boštan

···

On 8.10.2008, at 17:27, David Woods wrote:

FWIW, EVT_MEDIA_LOADED appears to work fine on Vista (and elsewhere) using
wxPython-2.8.7.1-unicode under Python 2.4.4. Or at least my app works on
Vista, even functions that should be dependent upon EVT_MEDIA_LOADED. If
you need me to double-check, I can, but I don't actually have Python or
wxPython loaded on the Vista computer.

Boštan,

It took a bit of work to get your simple sample working at all. I reduced
it to:

import wx
import wx.media

class DemoFrame(wx.Frame):
  def __init__(self,parent,id):
    wx.Frame.__init__(self,parent,id)
    self.mp = wx.media.MediaCtrl(self, size=wx.Size(512,384))
    self.mp.Bind(wx.media.EVT_MEDIA_LOADED,self.OnPlay)
    self.mp.Load("./demo.mpg")

  def OnPlay(self,event):
    print "playing"
            self.mp.Play()

app = wx.PySimpleApp()
frame=DemoFrame(parent=None,id=-1)

frame.Show()
app.MainLoop()

That got it working on XP with wxPython 2.8.7.1. I loaded Python and
wxPython on my Vista machine, and sure enough, even with the older wxPython,
the EVT_MEDIA_LOADED event doesn't fire. So that leaves me wondering why my
app DOES work on Vista. (It's py2exe'd and much more convoluted, but it
works.)

Unfortunately, I've run out of time to look into it for you. I've got to
get back on the clock now. I'll try to steal a bit more time in the next
few days.

David
http://www.transana.org

···

-----Original Message-----
From:
wxpython-users-bounces+dwoods=wcer.wisc.edu@lists.wxwidgets.or
g
[mailto:wxpython-users-bounces+dwoods=wcer.wisc.edu@lists.wxwi
dgets.org] On Behalf Of Boštjan Jerko
Sent: Wednesday, October 08, 2008 2:21 PM
To: wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] on load event and play in mediactrl

On 8.10.2008, at 17:27, David Woods wrote:

>>
> FWIW, EVT_MEDIA_LOADED appears to work fine on Vista (and elsewhere)
> using
> wxPython-2.8.7.1-unicode under Python 2.4.4. Or at least my app
> works on
> Vista, even functions that should be dependent upon
> EVT_MEDIA_LOADED. If
> you need me to double-check, I can, but I don't actually
have Python
> or
> wxPython loaded on the Vista computer.
>

Here is my test program (and it doesn't work). Even event is not
detected:

class DemoFrame(wx.Frame):
  def __init__(self,parent,id):
    wx.Frame.__init__(self,parent,id)
    self.mp = wx.media.MediaCtrl(self,
size=wx.Size(512,384))
     
self.mp.ShowPlayerControls(flags=wx.media.MEDIACTRLPLAYERCONTR
OLS_STEP)
    self.mp.Load("./uvod.mpg")
    self.Bind(wx.media.EVT_MEDIA_LOADED,self.OnPlay)

  def OnPlay(self,event):
    print "playing"
    if self.mpState == mpPLAYING:
      self.mp.Pause()
      self.mpState = mpPAUSED
      self.Msg('Paused: %s' % self.ActiveFile)
    else:
      self.slider.SetMax(self.mp.Length())
      self.mp.Play()
      self.mpState = mpPLAYING
      self.Msg('Playing %s' % self.ActiveFile)

app = wx.PySimpleApp()
frame=DemoFrame(parent=None,id=-1)

frame.Show()
app.MainLoop()

Any ideas?

Boštan

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

David,

thanks for the effort.
Tomorrow I'll try it on XP and see if there is a difference.

Boštjan

···

On 8.10.2008, at 22:06, David Woods wrote:

That got it working on XP with wxPython 2.8.7.1. I loaded Python and
wxPython on my Vista machine, and sure enough, even with the older wxPython,
the EVT_MEDIA_LOADED event doesn't fire. So that leaves me wondering why my
app DOES work on Vista. (It's py2exe'd and much more convoluted, but it
works.)

Unfortunately, I've run out of time to look into it for you. I've got to
get back on the clock now. I'll try to steal a bit more time in the next
few days.

David
http://www.transana.org

> That got it working on XP with wxPython 2.8.7.1. I loaded
Python and
> wxPython on my Vista machine, and sure enough, even with the older
> wxPython,
> the EVT_MEDIA_LOADED event doesn't fire. So that leaves me
> wondering why my
> app DOES work on Vista. (It's py2exe'd and much more convoluted,
> but it
> works.)
>
> Unfortunately, I've run out of time to look into it for you. I've
> got to
> get back on the clock now. I'll try to steal a bit more
time in the
> next
> few days.

thanks for the effort.
Tomorrow I'll try it on XP and see if there is a difference.

The mystery deepens.

I found and fixed a bug in my program, meaning I had to do a new build, so I
added code to confirm that the EVT_MEDIA_LOADED event was firing while I was
at it. It does fire, even on Vista, reliably.

I'll spend some time tomorrow working on why.

So we have very simple code that should work but doesn't, and much more
complex code that shouldn't work but does.

Sorry I can't be quicker, but I'm in the final throes of getting a major
release out the door before an international conference where I'm presenting
the new features. My video component used to work as a stand-alone, but I
appear to have broken that some time within the past couple of years since
the last time I ran it that way.

David

David Woods wrote:

That got it working on XP with wxPython 2.8.7.1. I loaded

Python and

wxPython on my Vista machine, and sure enough, even with the older
wxPython,
the EVT_MEDIA_LOADED event doesn't fire. So that leaves me wondering why my
app DOES work on Vista. (It's py2exe'd and much more convoluted, but it
works.)

Unfortunately, I've run out of time to look into it for you. I've
got to
get back on the clock now. I'll try to steal a bit more

time in the

next
few days.

thanks for the effort.
Tomorrow I'll try it on XP and see if there is a difference.

The mystery deepens.

I found and fixed a bug in my program, meaning I had to do a new build, so I
added code to confirm that the EVT_MEDIA_LOADED event was firing while I was
at it. It does fire, even on Vista, reliably.

I'll spend some time tomorrow working on why.

Do you use a non-default media player back-end?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

>>> That got it working on XP with wxPython 2.8.7.1. I loaded
>> Python and
>>> wxPython on my Vista machine, and sure enough, even with
the older
>>> wxPython, the EVT_MEDIA_LOADED event doesn't fire. So
that leaves
>>> me
>>> wondering why my
>>> app DOES work on Vista. (It's py2exe'd and much more
convoluted,
>>> but it
>>> works.)
>>>
>>> Unfortunately, I've run out of time to look into it for
you. I've
>>> got to get back on the clock now. I'll try to steal a bit more
>> time in the
>>> next
>>> few days.
>>
>> thanks for the effort.
>> Tomorrow I'll try it on XP and see if there is a difference.
>
>
> The mystery deepens.
>
> I found and fixed a bug in my program, meaning I had to do a new
> build, so I added code to confirm that the EVT_MEDIA_LOADED
event was
> firing while I was at it. It does fire, even on Vista, reliably.
>
> I'll spend some time tomorrow working on why.

Do you use a non-default media player back-end?

Robin,

Correct as usual. That's exactly the missing element.

Boštjan,

The following code loads and plays a video file, even on Vista, at least
under wxPython 2.8.7.1-unicode.

import wx
import wx.media

class DemoFrame(wx.Frame):
  def __init__(self,parent,id):
    wx.Frame.__init__(self,parent,id)
    self.mp = wx.media.MediaCtrl(self, fileName='./demo.mpg',
szBackend=wx.media.MEDIABACKEND_WMP10)
    self.mp.Bind(wx.media.EVT_MEDIA_LOADED,self.OnPlay)

  def OnPlay(self,event):
    print "playing"
          self.mp.Play()

app = wx.PySimpleApp()
frame=DemoFrame(parent=None,id=-1)

frame.Show()
app.MainLoop()

My suspicion is that MEDIABACKEND_DIRECTSHOW is the default back end on
Windows. If I understand things correctly, MEDIABACKEND_DIRECTSHOW relies
on the WMP 6.5 engine, which is included with Win2K and XP, but not with
Vista. Vista starts with the WMP 9/10 engine.

Just a side note, I find that SetPlaybackRate() doesn't work with the
MEDIABACKEND_WMP10 backend, though it does with MEDIABACKEND_QUICKTIME and
MEDIABACKEND_DIRECTSHOW. I also find that occasionally, but not reliably,
my program crashes when switching between the QuickTime and one of the WMP
back ends. Just crashes, taking everything down with it with no error
trapping possible. I haven't found a work-around to either of these
problems.

David