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 Source

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

C++ Source

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 Source

HWND  hwndFrame;   
IltmmPlay_put_VideoWindowFrame (pPlay, (long) hwndFrame); 

C++ Source

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 Source

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++ Source

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 Source

IltmmPlay_Run (pPlay); 

C++ Source

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 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Multimedia C API Help