IltmfPlay::SetPreferredMediaSourceHandler Example for C++

This example does the following:
1) Sets all preferred media source handlers to LEAD Default.
2) Then resets all preferred media source handlers to NULL, or does not use any preferred media source handlers.
3) Then sets the LEAD ISO Media Source Handler as the ISO Preferred media source handlers using its GUID.
4) Gets the preferred ISO Media Source Handler GUID.

void TestSetPreferredMediaSourceHandler(IltmfPlay *pPlay) 
{ 
   HRESULT hr = S_OK; 
   BSTR bstr = NULL; 
    
   // Setting all media source handlers to LEAD Default 
   bstr = SysAllocString(ltmfMediaSourceHandler_LEADDefault); 
   hr = pPlay->SetPreferredMediaSourceHandler(ltmfPlay_PreferredMediaSourceHandler_Generic, bstr); 
   SysFreeString(bstr); 
    
   // Resets all the preferred media source handlers to NULL, or don't use any preferred media source handler. 
   bstr = SysAllocString(ltmfMediaSourceHandler_DontCare); 
   hr = pPlay->SetPreferredMediaSourceHandler(ltmfPlay_PreferredMediaSourceHandler_Generic, bstr); 
   SysFreeString(bstr); 
    
   // Setting the ISO Media Source handler to the LEAD ISO Media Source handler, using it's GUID. 
   bstr = SysAllocString(L"EFE620B5-0A2C-49FA-8A01-3768B559B6DA"); 
   hr = pPlay->SetPreferredMediaSourceHandler(ltmfPlay_PreferredMediaSourceHandler_ISO, bstr); 
   SysFreeString(bstr); 
    
   // Gets the preferred ISO Media Source handler 
   bstr = NULL; 
   hr = pPlay->GetPreferredMediaSourceHandler(ltmfPlay_PreferredMediaSourceHandler_ISO, &bstr); 
    
   // check that the preferred handler for ISO media source is the LEAD ISO Media Source handler 
   if(bstr != NULL && !_wcsicmp(bstr, ltmfMediaSourceHandler_LEAD_ISO)) 
      MessageBox(NULL, TEXT("The preferred media source handler was set properly!"), TEXT("SUCCESS"), MB_OK); 
   else 
      MessageBox(NULL, TEXT("The preferred media source handler was not set properly!"), TEXT("FAILURE"), MB_OK); 
       
   // free the bstr 
   SysFreeString(bstr); 
} 

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

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