IltmmConvert::SetClosedCaptioningTargetFile Example for C++

// This function does the following: // 1) Sets a closed captioning target file and saves it in SRT format. // 2) Retrieves the file and its flag and makes sure it is properly set. // 3) Sets a closed captioning target file and saves it in TEXT format. // 4) Retrieves the file and its flag and makes sure it is properly set.

void TestSetClosedCaptioningTargetFile(IltmmConvert *pConvert) 
{ 
   HRESULT hr = S_OK; 
   BSTR bstrTargetFileSRT = NULL; 
   BSTR bstrTargetFileTEXT = NULL; 
   BSTR bstrTargetFile = NULL; 
   long Flags = 0; 
   bstrTargetFileSRT = SysAllocString(MAKE_MEDIA_PATH("ClosedCaptioning.srt")); 
   bstrTargetFileTEXT = SysAllocString(MAKE_MEDIA_PATH("ClosedCaptioning.txt")); 
    
   // Set the closed captioning target file to ClosedCaptioning.srt and save it in SRT format. 
   hr = pConvert->SetClosedCaptioningTargetFile(bstrTargetFileSRT, 0); 
   ASSERT( hr == S_OK); 
 
   bstrTargetFile = NULL; 
   hr = pConvert->GetClosedCaptioningTargetFile(&bstrTargetFile, &Flags); 
    
   if((hr == S_OK) && (VarBstrCmp(bstrTargetFile, bstrTargetFileSRT, NORM_IGNORECASE | LOCALE_USER_DEFAULT, 0) == static_cast<HRESULT>(VARCMP_EQ)) && (0==Flags) ) 
      MessageBox(NULL, TEXT("The Closed Captioning Target File was set properly!"), TEXT("SUCCESS"), MB_OK); 
   else 
      MessageBox(NULL, TEXT("The Closed Captioning Target File was NOT set properly!"), TEXT("FAILURE"), MB_OK); 
    
   // free the bstr 
   SysFreeString(bstrTargetFile); 
 
   // Set the closed captioning target file to ClosedCaptioning.txt and save it in TEXT format. 
   hr = pConvert->SetClosedCaptioningTargetFile(bstrTargetFileTEXT, ltmmClosedCaptioning_Text); 
   ASSERT( hr == S_OK); 
 
   bstrTargetFile = NULL; 
   hr = pConvert->GetClosedCaptioningTargetFile(&bstrTargetFile, &Flags); 
   if((hr == S_OK) && (VarBstrCmp(bstrTargetFile, bstrTargetFileTEXT, NORM_IGNORECASE | LOCALE_USER_DEFAULT, 0) == static_cast<HRESULT>(VARCMP_EQ)) && (ltmmClosedCaptioning_Text==Flags) ) 
      MessageBox(NULL, TEXT("The Closed Captioning Target File was set properly!"), TEXT("SUCCESS"), MB_OK); 
   else 
      MessageBox(NULL, TEXT("The Closed Captioning Target File was NOT set properly!"), TEXT("FAILURE"), MB_OK); 
 
   // free the bstrs 
   SysFreeString(bstrTargetFile); 
   SysFreeString(bstrTargetFileSRT); 
   SysFreeString(bstrTargetFileTEXT); 
} 

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

LEADTOOLS Multimedia C API Help