LEADTOOLS Multimedia (Leadtools.Multimedia assembly) Send comments on this topic. | Back to Introduction | Help Version 17.0.3.22
ErrorAbort Event
See Also 
Leadtools.Multimedia Namespace > CaptureCtrl Class : ErrorAbort Event



Occurs when an error has caused an operation abort.

Syntax

Visual Basic (Declaration) 
Public Event ErrorAbort As ErrorAbortEventHandler
Visual Basic (Usage)Copy Code
Dim instance As CaptureCtrl
Dim handler As ErrorAbortEventHandler
 
AddHandler instance.ErrorAbort, handler
C# 
public event ErrorAbortEventHandler ErrorAbort
C++/CLI 
public:
event ErrorAbortEventHandler^ ErrorAbort

Example

Visual BasicCopy Code
Public _result As Boolean = False
      Public _form As CaptureCtrlForm = New CaptureCtrlForm()
      Public _capturectrl As CaptureCtrl
      Public _totalTime As Double
      Public Sub ErrorAbortExample()
         ' reference the capture control
         _capturectrl = _form.CaptureCtrl

         ' output file
         Dim outFile As String = Path.Combine(LEAD_VARS.MediaDir, "CaptureCtrl_ErrorAbortTest.avi")

         Try
            ' set a test timer to interrupt the capture
            _form.TestTimer.Interval = 5000
            AddHandler _form.TestTimer.Tick, AddressOf TestTimer_Tick
            _form.TestTimer.Start()

            ' initialize the total capture time
            _totalTime = 0

            ' subscribe to the ErrorAbort event
            AddHandler _capturectrl.ErrorAbort, AddressOf CaptureCtrl_ErrorAbort

            ' subscribe to the event
            AddHandler _capturectrl.Progress, AddressOf CaptureCtrl_Progress

            ' set a video device, use the name of your device here
            If _capturectrl.VideoDevices("USB") Is Nothing Then
               Throw New Exception("No USB video device available")
            End If

            _capturectrl.VideoDevices("USB").Selected = True

            ' select the MPEG4 video compressor
            _capturectrl.VideoCompressors.Mpeg4.Selected = True

            ' set an audio device, use the name of your device here
            _capturectrl.AudioDevices("USB").Selected = True

            ' set the target output file
            _capturectrl.TargetFile = outFile

            ' only 10 seconds of capture time
            _capturectrl.TimeLimit = 10
            _capturectrl.UseTimeLimit = True

            ' capture it now!
            _capturectrl.StartCapture(CaptureMode.AutoFramesAndAudio)
         Catch e1 As Exception
            _result = False
         End Try

         ' we'll loop on the state and pump messages for this example.
         ' but you should not need to if running from a Windows Forms application.
         Do While _capturectrl.State = CaptureState.Running
            Application.DoEvents()
         Loop
      End Sub

      Public Sub TestTimer_Tick(ByVal sender As Object, ByVal e As EventArgs)
         ' stop the capture
         _capturectrl.StopCapture()
      End Sub

      Public Sub CaptureCtrl_Progress(ByVal sender As Object, ByVal e As ProgressEventArgs)
         _totalTime = _capturectrl.CaptureTime
      End Sub

      Public Sub CaptureCtrl_ErrorAbort(ByVal sender As Object, ByVal e As ErrorAbortEventArgs)
         ' set result
         _result = True
      End Sub

Public NotInheritable Class LEAD_VARS
   Public Const MediaDir As String = "C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 17\Media"
End Class
C#Copy Code
public bool _result = false;
      public CaptureCtrlForm _form = new CaptureCtrlForm();
      public CaptureCtrl _capturectrl;
      public double _totalTime;
      public void ErrorAbortExample()
      {
         // reference the capture control
         _capturectrl = _form.CaptureCtrl;

         // output file
         string outFile = Path.Combine(LEAD_VARS.MediaDir,"CaptureCtrl_ErrorAbortTest.avi");

         try
         {
            // set a test timer to interrupt the capture
            _form.TestTimer.Interval = 5000;
            _form.TestTimer.Tick += new EventHandler(TestTimer_Tick);
            _form.TestTimer.Start();

            // initialize the total capture time
            _totalTime = 0;

            // subscribe to the ErrorAbort event
            _capturectrl.ErrorAbort += new ErrorAbortEventHandler(CaptureCtrl_ErrorAbort);

            // subscribe to the event
            _capturectrl.Progress += new ProgressEventHandler(CaptureCtrl_Progress);

            // set a video device, use the name of your device here
            if (_capturectrl.VideoDevices["USB"] == null)
               throw new Exception("No USB video device available");

            _capturectrl.VideoDevices["USB"].Selected = true;

            // select the MPEG4 video compressor
            _capturectrl.VideoCompressors.Mpeg4.Selected = true;

            // set an audio device, use the name of your device here
            _capturectrl.AudioDevices["USB"].Selected = true;

            // set the target output file
            _capturectrl.TargetFile = outFile;

            // only 10 seconds of capture time
            _capturectrl.TimeLimit = 10;
            _capturectrl.UseTimeLimit = true;

            // capture it now!
            _capturectrl.StartCapture(CaptureMode.AutoFramesAndAudio);
         }
         catch (Exception)
         {
            _result = false;
         }

         // we'll loop on the state and pump messages for this example.
         // but you should not need to if running from a Windows Forms application.
         while (_capturectrl.State == CaptureState.Running)
            Application.DoEvents();
      }

      public void TestTimer_Tick(object sender, EventArgs e)
      {
         // stop the capture
         _capturectrl.StopCapture();
      }

      public void CaptureCtrl_Progress(object sender, ProgressEventArgs e)
      {
         _totalTime = _capturectrl.CaptureTime;
      }

      public void CaptureCtrl_ErrorAbort(object sender, ErrorAbortEventArgs e)
      {
         // set result
         _result = true;
      }

static class LEAD_VARS
{
   public const string MediaDir = @"C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 17\Media";
}

Remarks

The event handler is passed an ErrorAbortEventArgs. object containing the related error code. For more information, refer to the Error Codes.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also

Reference

CaptureCtrl Class
CaptureCtrl Members