SetPreferredMediaSourceHandler Method

Summary
Sets a preferred media source handler's GUID.
Syntax
C#
C++/CLI
public virtual void SetPreferredMediaSourceHandler( 
   PreferredMediaSourceHandler MediaSourceHandlerType, 
   string val 
) 
public: 
virtual void SetPreferredMediaSourceHandler(  
   PreferredMediaSourceHandler MediaSourceHandlerType, 
   String^ val 
)  

Parameters

MediaSourceHandlerType
A PreferredMediaSourceHandler enumeration value specifying the desired media source handler type

val
String with the following possible values:

Remarks

By default, the toolkit creates media sources according to the default Media Foundation mechanism, and thats by using a Source Resolver which is standard way to create media sources. However, sometimes 3rd party media sources get installed on some computers and assigns their media source handler to a specific media type and are used instead of the media sources you shipped with your application. And unexpected problems can occur if these media sources are not working properly. The SetPreferredMediaSourceHandler method allows you to control which media sources are used in your application. You can decide to use a certain media source handler or you can choose to use only the LEAD ones.

val is a string for the GUID of the media source handler.

This GUID uniquely identifies the media source handler. Every media format has a registered media source handler(s) who are responsible of creating a media source for this media type.

For example, the GUID for the LEAD MPEG2 Transport Media Source Handler is: EFE626C3-0A2C-49FA-8A01-3768B559B6DA

A list of display names for common media source handlers can be found in Constants.PreferredMediaSourceHandlers.

If the MediaSourceHandlerType parameter is equal to PreferredMediaSourceHandler.Generic, then the val parameter's possible values are: PreferredMediaSourceHandlers.LEADDefault or PreferredMediaSourceHandlers.DontCare. If PreferredMediaSourceHandlers.LEADDefault is specified, then default media source handlers will be set for all values listed in PreferredMediaSourceHandler. If PreferredMediaSourceHandlers.DontCare is specified, then the internal list of the preferred media source handler will be cleared and the media source will be created using the Media Foundation's default mechanism (Source Resolver).

It is recommended that you use the constants from Constants.PreferredMediaSourceHandlers whenever possible.

Example
C#
using Leadtools; 
using Leadtools.MediaFoundation; 
using LeadtoolsMediaFoundationExamples.Fixtures; 
 
 
public bool _result = false; 
public ConvertCtrlForm _form = new ConvertCtrlForm(); 
 
public void ConverterPreferredMediaSourceHandlersExample() 
{ 
   ConvertCtrl convertCtrl = _form.ConvertCtrl; 
 
   try 
   { 
      // set the preferred MPEG2Transport media source handler to the LEAD default (which is the LEAD MPEG2 Transport Media Source handler) 
      convertCtrl.SetPreferredMediaSourceHandler(PreferredMediaSourceHandler.MPEG2Transport, Constants.PreferredMediaSourceHandlers.LEADDefault); 
 
      // the default MPEG2Transport media source should be the LEAD MPEG2 Transport Media Source handler now 
      _result = (string.Compare(convertCtrl.GetPreferredMediaSourceHandler(PreferredMediaSourceHandler.MPEG2Transport), 
                 Constants.PreferredMediaSourceHandlers.MPEG2Transport, true) == 0); 
   } 
   catch (Exception) 
   { 
      _result = false; 
   } 
} 
Requirements

Target Platforms

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

Leadtools.MediaFoundation Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.