Sets a preferred filter (decoder or demultiplexer)
Public Overridable Sub SetPreferredFilter( _
ByVal filterType As PreferredFilter, _
ByVal val As String _
A PreferredFilter enumeration value specifying the desired filter type
String with the following possible values:
By default, the toolkit uses filters according to the default DirectShow mechanism, which assigns a merit to each filter. The filters with the highest merits are tried first. If they fail, the filters with a lower merit are tried next until a combination of filters is found that can handle the graph.
Starting with Windows 7, there is also a list of preferred filters for certain media types. These filters will be used by default instead of filters with higher merit.
3rd party filters can also get installed on some computers with a high merit and might be used instead of the filters you shipped with your application. Unexpected problems can occur if the Microsoft preferred or the 3rd party filters are not working properly. The SetPreferredFilter method allows you to control which filters are used in your application. You can decide to use a certain decoder, demultiplexer or you can choose to use only the LEAD filters.
DirectShow filters have a friendly name and a display name. The friendly name is easy to remember and is usually displayed by GraphEdit or other filter enumeration utilities. But there can be more than one filter with the same friendly name, so it is safer to use the display name, since no two filters have the same display name.
val is a string for the Display Name or Friendly Name of the filter. If Friendly Name is used, this function will choose the first filter it finds with the specified friendly name.
Display names for software filters have the following format:
For example Microsoft's MPEG-2 Splitter has:
friendly name: MPEG-2 Splitter
The display name for a particular filter can be obtained from the "DirectShow Filter List Utility" (ltmmListFilters.exe) shipped with the toolkit. See Examples Programs and Demos for Win32/x64 in the Multimedia API help file for more details.
If the filterType parameter is equal to PreferredFilter.Generic, then the filterName parameter's possible values are: PreferredFilters.LEADDefault or PreferredFilters.DontCare. If PreferredFilters.LEADDefault is specified, then default decoders and demultiplexers will be set for all values listed in PreferredFilter. If PreferredFilters.DontCare is specified, then the internal list of the preferred filters will be cleared and the DirectShow filter merit determines which filters will be used.
It is recommended that you use the constants from Constants.PreferredFilters whenever possible.
public bool _result = false;
public PlayCtrlForm _form = new PlayCtrlForm();
public void PlayerPreferredFiltersExample()
PlayCtrl playctrl = _form.PlayCtrl;
// set the preferred mpeg2 decoder to the LEAD default (which is the LEAD MPEG2 Decoder)
// the default mpeg2 decoder should be the LEAD MPEG2 decoder now
// the filter names are not case sensitive, so ignore case in the compare
_result = (string.Compare(playctrl.GetPreferredFilter(PreferredFilter.MPEG2Decompressor),
Constants.PreferredFilters.MPEG2Decompressor, true) == 0);
_result = false;
Public _result As Boolean = False
Public _form As PlayCtrlForm = New PlayCtrlForm()
Public Sub PlayerPreferredFiltersExample()
' reference the forms capture control
Dim playctrl As PlayCtrl = _form.PlayCtrl
' set the preferred mpeg2 decoder to the LEAD default (which is the LEAD MPEG2 Decoder)
' the default mpeg2 decoder should be the LEAD MPEG2 decoder now
' the filter names are not case sensitive, so do ignore the case in the compare
_result = (String.Compare(playctrl.GetPreferredFilter(PreferredFilter.MPEG2Decompressor),
Leadtools.Multimedia.Constants.PreferredFilters.MPEG2Decompressor, True) = 0)
Catch e1 As Exception
_result = False
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries