Solved

MCI, playing an AVI, using my own window

Posted on 1997-05-08
1
422 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now