LEADTOOLS Multimedia (Leadtools.Multimedia assembly)
LEAD Technologies, Inc

IsValidCompressor Method

Example 





A String value representing the name of the Compressor to check for validity.
Gets a value that indicates if the specified compressor is valid for the currently selected target format.
Syntax
public TargetFormatCompressor IsValidCompressor( 
   string Name
)
'Declaration
 
Public Function IsValidCompressor( _
   ByVal Name As String _
) As TargetFormatCompressor
'Usage
 
Dim instance As TargetFormat
Dim Name As String
Dim value As TargetFormatCompressor
 
value = instance.IsValidCompressor(Name)
public TargetFormatCompressor IsValidCompressor( 
   string Name
)
 function Leadtools.Multimedia.TargetFormat.IsValidCompressor( 
   Name 
)
public:
TargetFormatCompressor IsValidCompressor( 
   String^ Name
) 

Parameters

Name
A String value representing the name of the Compressor to check for validity.

Return Value

An TargetFormatCompressor enumeration value indicating Invalid, Indeterminate, or Valid.
Remarks
Gets a value that indicates if the specified compressor is valid for the currently selected target format. This includes the file format, any special settings used by that format, and which audio and video codec is in the CaptureCtrl or ConvertCtrl parent object.
Example
Copy CodeCopy Code  
Public _result As Boolean = False
Public _form As CaptureCtrlForm = New CaptureCtrlForm()
Public Sub HasCacheDialogExample()
   ' reference the capture control
   Dim capturectrl As CaptureCtrl = _form.CaptureCtrl

   Try
      ' set a video device first, you should use your video device name here
      If capturectrl.VideoDevices("Analog") Is Nothing Then
         Throw New Exception("No Analog audio device available")
      End If

      capturectrl.VideoDevices("Analog").Selected = True

      ' set the video compressor
      capturectrl.VideoCompressors.Mpeg2.Selected = True

      ' reference the target formats collection
      Dim fmt As TargetFormat = capturectrl.TargetFormats.MPEG2Program

      ' enumerate through the list of formats
      For Each af As TargetFormat In capturectrl.TargetFormats
         ' check the formats valid compressor and stream type
         Dim isValid As Boolean = (af.IsValidCompressor(capturectrl.VideoCompressors.Mpeg2.Name) = TargetFormatCompressor.Valid)
         Dim types As StreamFormatType = af.Streams

         ' if valid, select it
         If isValid AndAlso ((types And StreamFormatType.Video) = StreamFormatType.Video) Then
            fmt = af
            fmt.Selected = True
            Exit For
         End If
      Next af

      ' check to see if the current target format has a cache dialog
      If Not fmt Is Nothing AndAlso fmt.HasCacheDialog(TargetFormatDlg.VideoCompressor) Then
         ' show the dialog
         fmt.ShowCacheDialog(TargetFormatDlg.VideoCompressor, _form)

         ' set the result
         _result = True
      End If
   Catch e1 As Exception
      _result = False
   End Try
End Sub
public bool _result = false;
public CaptureCtrlForm _form = new CaptureCtrlForm();
public void HasCacheDialogExample()
{
   // reference the capture control
   CaptureCtrl capturectrl = _form.CaptureCtrl;

   try
   {
      // set a video device first.  use your video device's name here
      if (capturectrl.VideoDevices["Analog"] == null)
         throw new Exception("No Analog audio device available");

      capturectrl.VideoDevices["Analog"].Selected = true;

      // set the video compressor
      capturectrl.VideoCompressors.Mpeg2.Selected = true;

      // reference the target formats collection
      TargetFormat fmt = capturectrl.TargetFormats.MPEG2Program;

      // enumerate through the list of formats
      foreach (TargetFormat af in capturectrl.TargetFormats)
      {
         // check the formats valid compressor and stream type
         bool isValid = (af.IsValidCompressor(capturectrl.VideoCompressors.Mpeg2.Name) == TargetFormatCompressor.Valid);
         StreamFormatType types = af.Streams;

         // if valid, select it
         if (isValid && ((types & StreamFormatType.Video) == StreamFormatType.Video))
         {
            fmt = af;
            fmt.Selected = true;
            break;
         }
      }

      // check to see if the current target format has a cache dialog
      if (fmt != null && fmt.HasCacheDialog(TargetFormatDlg.VideoCompressor))
      {
         // show the dialog
         fmt.ShowCacheDialog(TargetFormatDlg.VideoCompressor, _form);

         // set the result
         _result = true;
      }
   }
   catch (Exception)
   {
      _result = false;
   }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

TargetFormat Class
TargetFormat Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Multimedia requires a Multimedia or Multimedia Suite license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features