We help IT Professionals succeed at work.

Cannot center AVI output using MMControl in program

709 Views
Last Modified: 2013-12-21
I am writing a game using visual basic 5 SP3 on an XP Pro SP2 system that is using avi video (with sound) for different actions.  I am using the Microsoft Multimedia Control to play the AVI files.  All works well and the files play when they are supposed to but I cannot get the control to center the AVI.  No matter what I set width, height, left and top to... the AVI plays in the upper left of the screen.  I am using a 640 x 480 AVI on a screen that is 1440 x 900.  Twips per pixel is 15.  I have used formulas to calculate center screen on all my other forms and they all center nicely... just the MM Control will not.  I have tried placing my centering code before and after each step of the command codes to play the avi and nothing changes.  Any ideas?
Comment
Watch Question

Jose ParrotGraphics Expert
CERTIFIED EXPERT

Commented:
Hi,

You can use the following approach.
1. Read the AVI file to know the video size in pixels. How to at
http://msdn2.microsoft.com/en-us/library/Aa451195.aspx
2. Create a Panel object with Height and Width properties set to the above video size.
3. Centralize the Panel
4. Apply the MediaPlayer (Multimedia control) object in the Panel, aligned at top and left (default), that is, the MM->Display is the Panel.

That way, the video will be where you want, in the right size.

Jose

Author

Commented:
Thanks Jose.  I tried creating a separate form, centering the form and then adding the MMControl in it to accomplish the same thing, but that didn't work.  

I hate to admit it... but I am not familiar with the Panel Object.  I tried to create one programmatically using code found on google, but I got errors when I tried to add the MMControl to it.  I cannot find much documentation on it, either.  Is this the same panel object that is referenced as part of the status bar control?  Do you know where I can find code and/or information on how it functions and how to use it?  Thanks again for your response.
Jose ParrotGraphics Expert
CERTIFIED EXPERT

Commented:
Hummmm. As I use Borland Builder C++, I can create a Panel with a single click...
Not so easy in other environments, where you need to type a LOT of code...

If you are using Visual C++ (or even a non-graphics C++ development environment, as free Borland C++ compiler 5) take a look at the MSDN sample aviview.dsp and companion files.
It uses another approach, with PAVISTREAM, but not only put the AVI centralized as can resize the video frame as well.
The source for Visual C++ 6.0 (works with any C++ compiler from Windows 95 to xP) is at
samples/vc98/sdk/graphics/video/aviview of the MSDN disc.

Jose
Jose ParrotGraphics Expert
CERTIFIED EXPERT

Commented:
Answering your question on Status Bar: no, it is not the same panel I'm talking about, althougth similar.

I have searched for the sample code I have cited in MSDN site, but it is not available anymore.

At ebay you find Microsoft MSDN Library for Visual Studio 6.0 CDs at very low prices. It worth the investment. Please note: version 6 will compile and link with open source compilers besides VS 6 and Borland C++; newer versions aren't guaranteed to integrate properly.

Jose

Author

Commented:
I ended up using the Windows Media Player control (after hours of experimentation) which seems to work for my needs just fine.  It centers, plays the clips with no controls and then closes, which is what I was trying to accomplish.  I still don't know why the MMControl won't center, but I will deal with the "panel" issue when I have more time.  It sounds like something I need to familiarize myself with.  I am not sure how the rules here go... I didn't end up using your advice (although it lead me to another humbling "I don't know as much as I thought I did" experience), but your response is greatly appreciated.  I would like to give you the points anyway... if someone will tell me that that is okay to do.  Thanx again.
Graphics Expert
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.