Solved

MCI, playing an AVI, using my own window

Posted on 1997-05-08
1
428 Views
Last Modified: 2013-12-04
I am using the Media Control Interface to play an AVI file.  I can easily open, play and close the AVI file.  By default the video plays in it's own window that is created on play.

This is all fine--but unfortunately I want to play the AVI file within my own window.  To do this, I have done the following after issuing the open command:

  MCI_DGV_WINDOW_PARMS params;
  params.hWnd = wnd.m_hWnd;
  if (mciSendCommand(m_OpenParams.wDeviceID,
                       MCI_WINDOW,
                       MCI_DGV_WINDOW_HWND,
                       (unsigned long)&params) != 0)
  {
    return FALSE; // some error
  }

This works... well sort of.  When the video initially displays, it appears fine.  But as soon as it begins to play, the video appears garbled.

My guess is I might need to handle screen updates or something.  Unfortunately I can't find any documentation or samples for this.

Thanks in advance.

0
Comment
Question by:BrindleFly
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 100 total points
ID: 1397178
When you say it appears garbled, does it mean the color of the video changes or the image changes or something else? Do you have your own color palette operation in your window? My program plays AVI files in my own window fine. I don't think you need to handle screen updates.

The following code was extracted from Video For Windows 1.1 Programmer's Guide.

The following fragment finds the dimensions needed to play an AVI file, creates a window corresponding to that size, and has MCIAVI to play the file in the window:

HWND        hwnd;
MCI_DGV_RECT_PARMS mciRect;

// Get the movie dimensions with MCI_WHERE.
mciSendCommand(wDeviceID, MCI_WHERE, MCI_DGV_WHERE_SOURCE,
    (DWORD)(LPSTR)&mciRect);

// Create the playback window. Make it bigger for the border.
hwndMovie = CreateWindow("mywindow", "Playback",
                         WS_CHILD|WS_BORDER, 0,0,
                         mciRect.rc.right+(2*GetSystemMetric(SM_CXBORDER)),                         mciRect.rc.bottom+(2*GetSystemMetric(SM_CYBORDER)),

                         hwndParent, hInstApp, NULL);

if (hwndMovie){
    // Window created OK, make it the playback window.

    MCI_DGV_WINDOW_PARMS    mciWindow;

    mciWindow.hWnd = hwndMovie;
    mciSendCommand(wDeviceID, MCI_WINDOW, MCI_DGV_WINDOW_HWND,
                   (DWORD)(LPSTR)&mciWindow);

}


The following fragment shows how to display the window using the command message interface:

MCI_DGV_WINDOW_PARMS    mciWindow;

mciWindow.nCmdShow = SW_SHOW;    // set command - see ShowWindow()
mciSendCommand(wDeviceID, MCI_WINDOW, MCI_DGV_WINDOW_STATE,
               (DWORD)(LPSTR)&mciWindow);

0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question