wxMediaCtrl questions

I'm trying to replace Transana's custom media control code with wxMediaCtrl.
Transana currently runs on Windows and Mac, though wxMediaCtrl may buy us a
Linux version for the folks who've asked us about it. Mostly it's working
really well, but there are a few issues. Some I think just can't be done,
and some I just can't seem to figure out.

1. Is there a way to get the MediaCtrl to tell you the original dimensions
of a video it's loaded? Both Media Player and QuickTime provide methods for
this, but I don't see a way to access the information from wxMediaCtrl.

2. I can't seem to select the QuickTime player on Windows when I need it.
I can't find the right szBackend constant to pass in the Create() method.
There don't appear to be any wx.MEDIABACKEND_... constant definitions that I
can find. help(wx.media.MediaCtrl) suggests that I need to pass a string,
but I can't find a value that works.

3. ShowPlayerControls() works on Windows, but produces an AttributeError on
the Mac. "AttributeError: 'MediaCtrl' object has no attribute
'ShowPlayerControls'". Is there a way to show the player's controls on the
Mac?

4. ShowPlayerControls() on Windows is supposed to be able to take some
parameters or flags. How do I find out what the legal values are?
Specifically, I need to have the Player Control Buttons, but I'd prefer not
to have the status display area below the buttons. Media Player has a
method for setting "showdisplay = False" to turn this area off. Is there a
way to accomplish this using ShowPlayerControls()? Is there any way to do
it?

5. My current implementation loads a gif image into the media player when
my program starts to be displayed before a video file is selected. The
image doesn't display using wx.MediaCtrl. Also, when I load a movie using
the Load() method, the video's first frame isn't displayed until I call
"Play", unlike my current implementation. Any idea why not? (This is
obviously a small, cosmetic issue, but I'd like to be able to keep my
program's appearance consistent.)

I've attached a little Media Controller program for your convenience if
you'd like to see it. I need the capacity to control the video from other
windows, so I've separated the video presentation and the video controller,
and the choices I've made in this example match the requirements for
Transana.

Thanks in advance.

David K. Woods, Ph.D.
Transana Lead Developer
Wisconsin Center for Education Research
University of Wisconsin, Madison
http://www.transana.org

  "Quick. Cheap. Good. Pick two."

video_crossplatform.py (9.71 KB)

David Woods wrote:

I'm trying to replace Transana's custom media control code with wxMediaCtrl.
Transana currently runs on Windows and Mac, though wxMediaCtrl may buy us a
Linux version for the folks who've asked us about it. Mostly it's working
really well, but there are a few issues. Some I think just can't be done,
and some I just can't seem to figure out.

1. Is there a way to get the MediaCtrl to tell you the original dimensions
of a video it's loaded? Both Media Player and QuickTime provide methods for
this, but I don't see a way to access the information from wxMediaCtrl.

There is not a separate API for it but you can use GetBestSize as it is calculated dynamically based on the size of the currently loaded video.

2. I can't seem to select the QuickTime player on Windows when I need it.
I can't find the right szBackend constant to pass in the Create() method.
There don't appear to be any wx.MEDIABACKEND_... constant definitions that I
can find. help(wx.media.MediaCtrl) suggests that I need to pass a string,
but I can't find a value that works.

Hmm... Looks like these got left out of the wxPython wrappers. I'll add them, but in the meantime you can use these strings:

#define wxMEDIABACKEND_DIRECTSHOW wxT("wxAMMediaBackend")
#define wxMEDIABACKEND_MCI wxT("wxMCIMediaBackend")
#define wxMEDIABACKEND_QUICKTIME wxT("wxQTMediaBackend")
#define wxMEDIABACKEND_GSTREAMER wxT("wxGStreamerMediaBackend")

3. ShowPlayerControls() works on Windows, but produces an AttributeError on
the Mac. "AttributeError: 'MediaCtrl' object has no attribute
'ShowPlayerControls'". Is there a way to show the player's controls on the
Mac?

What version? ShowPlayerControls is in all ports in 2.6.2.1.

4. ShowPlayerControls() on Windows is supposed to be able to take some
parameters or flags. How do I find out what the legal values are?
Specifically, I need to have the Player Control Buttons, but I'd prefer not
to have the status display area below the buttons. Media Player has a
method for setting "showdisplay = False" to turn this area off. Is there a
way to accomplish this using ShowPlayerControls()? Is there any way to do
it?

Looks like these flags are missing too. (Somebody was asleep at the wheel...)

enum wxMediaCtrlPlayerControls
{
     wxMEDIACTRLPLAYERCONTROLS_NONE = 0,
     //Step controls like fastfoward, step one frame etc.
     wxMEDIACTRLPLAYERCONTROLS_STEP = 1 << 0,
     //Volume controls like the speaker icon, volume slider, etc.
     wxMEDIACTRLPLAYERCONTROLS_VOLUME = 1 << 1,
     wxMEDIACTRLPLAYERCONTROLS_DEFAULT =
                     wxMEDIACTRLPLAYERCONTROLS_STEP |
                     wxMEDIACTRLPLAYERCONTROLS_VOLUME
};

5. My current implementation loads a gif image into the media player when
my program starts to be displayed before a video file is selected. The
image doesn't display using wx.MediaCtrl. Also, when I load a movie using
the Load() method, the video's first frame isn't displayed until I call
"Play", unlike my current implementation. Any idea why not? (This is
obviously a small, cosmetic issue, but I'd like to be able to keep my
program's appearance consistent.)

No idea, and I've wondered this too. The initial implementation on Windows did show the first frame, but when it was redesigned to better support the other platforms with the same API then it stopped doing it.

I haven't looked at it yet but there is a big patch for the MediaCtrl that is about to be checked in for 2.7, so some things may be changing again there.

···

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

Robin,

Thanks for the answers to most of my questions. I won't be able to really
play with it again until Monday, but I do have some follow-up now.

> 1. Is there a way to get the MediaCtrl to tell you the original
> dimensions of a video it's loaded? Both Media Player and QuickTime
> provide methods for this, but I don't see a way to access
the information from wxMediaCtrl.

There is not a separate API for it but you can use
GetBestSize as it is
calculated dynamically based on the size of the currently
loaded video.

I see why I missed this. I called GetBestSize() immediately after loading,
and it was returning (0, 0). I see that if I call it much later in the
process, it does return a legitimate size.

> 3. ShowPlayerControls() works on Windows, but produces an
> AttributeError on the Mac. "AttributeError: 'MediaCtrl'
object has no
> attribute 'ShowPlayerControls'". Is there a way to show
the player's
> controls on the Mac?

What version? ShowPlayerControls is in all ports in 2.6.2.1.

wxPython 2.6.1.0-unicode on the Mac. I'm two weeks shy of a release I've
put 8 months into, so have resisted upgrading. The release won't include
the wx.MediaCtrl upgrade, so as long as I know it's there in the next
wxPython, I'm happy.

> 4. ShowPlayerControls() on Windows is supposed to be able to take
> some parameters or flags. How do I find out what the legal values
> are? Specifically, I need to have the Player Control
Buttons, but I'd
> prefer not to have the status display area below the
buttons. Media
> Player has a method for setting "showdisplay = False" to turn this
> area off. Is there a way to accomplish this using
> ShowPlayerControls()? Is there any way to do it?

Looks like these flags are missing too. (Somebody was asleep at the
wheel...)

enum wxMediaCtrlPlayerControls
{
     wxMEDIACTRLPLAYERCONTROLS_NONE = 0,
     //Step controls like fastfoward, step one frame etc.
     wxMEDIACTRLPLAYERCONTROLS_STEP = 1 << 0,
     //Volume controls like the speaker icon, volume slider, etc.
     wxMEDIACTRLPLAYERCONTROLS_VOLUME = 1 << 1,
     wxMEDIACTRLPLAYERCONTROLS_DEFAULT =
                     wxMEDIACTRLPLAYERCONTROLS_STEP |
                     wxMEDIACTRLPLAYERCONTROLS_VOLUME
};

So I'm stuck with the status area on Media Player then. Bummer.

Thanks for your help, as always.

David

> 3. ShowPlayerControls() works on Windows, but produces an
> AttributeError on the Mac. "AttributeError: 'MediaCtrl'
object has no
> attribute 'ShowPlayerControls'". Is there a way to show
the player's
> controls on the Mac?

What version? ShowPlayerControls is in all ports in 2.6.2.1.

Okay, it appears to be missing in 2.6.1.0-unicode, and merely broken in
2.6.1.2-unicode. Using 2.6.1.2, there is in fact a bar in place the color
and size expected for the player controls. However, the bar is blank and
unresponsive.