c++mci

MCIWindow with long file path


I have come across a scenario in my project, where I am creating a MCI window in order to play some videos, wherein it does not play correctly when there is a filepath passed to it which is more than 128 characters long.

I am creating a new MCIWindow like so:

m_window = MCIWndCreate( _owner, GetModuleHandle(NULL), WS_CHILD|MCIWNDF_NOERRORDLG|MCIWNDF_NOPLAYBAR|MCIWNDF_NOMENU, shortPath.c_str() );

and it will later get played by doing the below:

bool VideoMedia::play() 
{
    logStream().I() << "[VideoMedia::play] start\n";

    if ( MCIWndPlay( m_window ) != 0 )
    {
        logStream().E() << "VideoMedia::play " << "\n";
    }
    logStream().I() << "[VideoMedia::play] end\n";
    return true;
}

In the case where I am creating the m_window using a shortPath with length < 128, everything is working perfectly fine with the media showing and playing. However, with a shortPath with length > 128, no media is played. Interestingly, in the VideoMedia::play() function above, the logs indicate that the MCIWndPlay() call is executing fine, as the error log inside of the if is not seen.

I am wondering if this is just the case that the MCIWnd can not support a long file path, although I have not seen anything in the documentation to suggest this is the case?


Solution

  • From looking at documentation here, it says:

    NOTE: MCI device has a path-length limit of 128 characters! If your media files are buried inside the nested subfolders and the path is longer than 128 characters, your media won't play.
    

    So the only real resolution for this is to ensure that the path does not get any larger than the 128 character restriction it appears.