Use ltmmPlay for Simple Playback

The ltmmPlay object allows the user to playback multimedia files.

  1. To begin a simple playback you will first need to create an instance of the ltmmPlay class. This is accomplished using the Win32 CoCreateInstance function as follows:

    C API
    IltmmPlay* pPlay;   
    CoCreateInstance(&CLSID_ltmmPlay, NULL, CLSCTX_INPROC_SERVER, &IID_IltmmPlay, (void**) &pPlay); 
    C++
    IltmmPlay* pPlay;   
    CoCreateInstance(&CLSID_ltmmPlay, NULL, CLSCTX_INPROC_SERVER, &IID_IltmmPlay, (void**) &pPlay); 

    The function creates an instance of ltmmPlay and returns an IltmmPlay interface pointer. It is through the IltmmPlay interface that playback is controlled.

  2. Define a frame window for the playback:

    C API
    HWND  hwndFrame;   
    IltmmPlay_put_VideoWindowFrame (pPlay, (long) hwndFrame); 
    C++
    HWND hwndFrame;   
    pPlay->put_VideoWindowFrame((long) hwndFrame); 

    The user is required to create the window that serves as the video frame. ltmmPlay will subclass this window, so there is no need to forward any messages to the ltmmPlay object. By default, ltmmPlay will automatically maximize the video within the frame window. The video will automatically resize when the frame window size changes.

  3. Define the source or input file. As demonstrated with the following code:

    C API
    BSTR bstr;    
    // create a string containing the source file path   
    bstr = SysAllocString(L"c:\\source.avi");    
    // assign the source file path to the play object   
    IltmmPlay_put_SourceFile (pPlay,  bstr);    
    // free the string   
    SysFreeString(bstr); 
    C++
    BSTR bstr;    
    // create a string containing the source file path   
    bstr = SysAllocString(L"c:\\source.avi");    
    // assign the source file path to the play object   
    pPlay->put_SourceFile(bstr);    
    // free the string   
    SysFreeString(bstr); 

    The code above allocates a string containing an AVI file path and assigns the path to the play object with a call to put_SourceFile.

  4. Start the playback:

    C API
    IltmmPlay_Run (pPlay); 
    C++
    pPlay->Run (); 
    The playback will continue until the end of the media file. It will then stop the playback and reset the video position to the start of the file.

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Multimedia C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.