Problem with playing mutiple AVIs with MCIWnd

Discussion in 'Amateur Video Production' started by Mike Donovan, Dec 31, 2003.

  1. Mike Donovan

    Mike Donovan Guest

    Hi,

    I am trying to play mutiple AVIs with MCIWnd, sequentially. That is, I
    create an MCIWnd object with MCWndCreate, i.e. :

    HWND hwnd = MCIWndCreate ( m_hWnd, AfxGetApp( ) -> m_hInstance,
    WS_EX_WINDOWEDGE|WS_VISIBLE|MCIWNDF_NOMENU|WS_EX_TOPMOST|MCIWNDF_NOTIFYMODE
    , "myfile.avi" ) ;
    m_hChildWnd=hwnd; // store handle for later reference

    Then I call play, adjust volume etc, and all is fine.

    When the file either finishes playing, or is interrupted by the user
    clicking a dialog button, I call:

    MCIWndClose(hwnd);
    MCIWndDestroy(hwnd);

    This closes the window, but does not stop playback of the AVI.
    After much searching on the net (posts/pages on MCI are VERY few and
    far between), if found a code fragment from MS Journal Jan 95 or 96
    which does the following:
    UINT uDevice = MCIWndGetDeviceID(m_hChildWnd);
    SendMessage(MCI_CLOSE, MCI_WAIT, 0);
    if (uDevice>0) {
    ////// [comments from original code from MSJ]
    // SendMessage(MCI_CLOSE) doesn't seem to close the device
    DWORD dwErr = mciSendCommand(uDevice, MCI_CLOSE, MCI_NOTIFY, 0);
    }
    This seemed to do the job: the AVI playback was killed as well.
    -------
    After that, my code creates another window using the original
    procedure above, and that too plays fine.

    The problem comes when I try to close the MCIWnd which was created
    second. When the MCI_CLOSE command is sent, my program has an
    application error. From what I can read of the Japanese error dialog,
    my app is trying to read memory which it is not allowed to (is that
    called an 'access violation' ?). When I click cancel to debug, I get
    a dialog (in English) from Visual Studio saying it cannot execute the
    program (debugger I assume)).

    I'm pretty lost now. I think it's got something to do with what
    MCIWnd is doing internally with its mysterious macros. Maybe by making
    the second MCI_CLOSE call I'm somehow using a pointer which has been
    dereferenced somewhere in MS code. I've been battling in the dark to
    get this far, but I'm stumped. I would sure appreciate some help if
    anyone can assist.

    Cheers
    Mike
     
    Mike Donovan, Dec 31, 2003
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.