LEADTOOLS Multimedia (Leadtools.MediaFoundation assembly)

ErrorAbort Event (ConvertCtrl)

Show in webframe
Example 



Occurs when an error has caused an operation to abort.
Syntax
'Declaration
 
Public Event ErrorAbort As ErrorAbortEventHandler
'Usage
 
Dim instance As ConvertCtrl
Dim handler As ErrorAbortEventHandler
 
AddHandler instance.ErrorAbort, handler
public event ErrorAbortEventHandler ErrorAbort
public:
event ErrorAbortEventHandler^ ErrorAbort
Remarks
The event handler is passed an ErrorAbortEventArgs object containing the related error code.

For more information, refer to the Error Codes.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.MediaFoundation
Imports LeadtoolsMediaFoundationExamples.Fixtures

Public _result As Boolean = False
Public _form As ConvertCtrlForm = New ConvertCtrlForm()
Public Sub ErrorAbortExample()
   ' reference the convert control
   Dim convertctrl As ConvertCtrl = _form.ConvertCtrl

   convertctrl.Window = _form.Handle

   ' input and output file names
   Dim inFile As String = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_Source.avi")
   Dim outFile As String = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_ErrorAbortExample.mp4")

   Try
      ' subscribe to the ErrorAbort event
      AddHandler convertctrl.ErrorAbort, AddressOf ConvertCtrl_ErrorAbort

      ' set the allowed streams and target type
      convertctrl.AllowedStreams = convertctrl.TargetFormats(TargetFormatType.MP4).Streams
      convertctrl.TargetFormat = TargetFormatType.MP4

      ' no recompression for video and audio
      Dim index As Integer = -1
      Dim trgvideoformats As TargetVideoFormats = convertctrl.TargetFormats(convertctrl.TargetFormat).VideoFormats
      index = trgvideoformats.IndexOf("{00000000-0000-0000-0000-000000000000}") ' NULL GUID name for no recompression
      trgvideoformats.Selection = index
      Dim trgaudioformats As TargetAudioFormats = convertctrl.TargetFormats(convertctrl.TargetFormat).AudioFormats
      index = trgaudioformats.IndexOf("{00000000-0000-0000-0000-000000000000}") ' NULL GUID name for no recompression
      trgaudioformats.Selection = index

      ' set the source and target files
      convertctrl.SourceFile = inFile
      convertctrl.TargetFile = outFile

      ' show preview
      convertctrl.Preview = True

      ' convert it now!
      convertctrl.StartConvert()
   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 convertctrl.State = ConvertState.Running
      Application.DoEvents()
   Loop
End Sub

Public Sub ConvertCtrl_ErrorAbort(ByVal sender As Object, ByVal e As ErrorAbortEventArgs)
   ' uncomment this line to show the error message
   ' MessageBox.Show(e.errorMessage, "Convert Error");

   ' set result
   _result = True
End Sub

Public NotInheritable Class LEAD_VARS
Public Const MediaDir As String = "C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 18\Media"
End Class
using Leadtools;
using Leadtools.MediaFoundation;
using LeadtoolsMediaFoundationExamples.Fixtures;

public bool _result = false;
public ConvertCtrlForm _form = new ConvertCtrlForm();
public void ErrorAbortExample()
{
   // reference the convert control
   ConvertCtrl convertctrl = _form.ConvertCtrl;

   convertctrl.Window = _form.Handle;

   // input and output file names
   string inFile = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_Source.avi");
   string outFile = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_ErrorAbortExample.mp4");

   try
   {
      // subscribe to the ErrorAbort event
      convertctrl.ErrorAbort += ConvertCtrl_ErrorAbort;

      // set the allowed streams and target type
      convertctrl.AllowedStreams = convertctrl.TargetFormats[TargetFormatType.MP4].Streams;
      convertctrl.TargetFormat = TargetFormatType.MP4;

      // no recompression for video and audio
      int index = -1;
      TargetVideoFormats targetvideoformats = convertctrl.TargetFormats[convertctrl.TargetFormat].VideoFormats;
      index = targetvideoformats.IndexOf("{00000000-0000-0000-0000-000000000000}");// NULL GUID name for no recompression
      targetvideoformats.Selection = index;
      TargetAudioFormats targetaudioformats = convertctrl.TargetFormats[convertctrl.TargetFormat].AudioFormats;
      index = targetaudioformats.IndexOf("{00000000-0000-0000-0000-000000000000}");// NULL GUID name for no recompression
      targetaudioformats.Selection = index;

      // set the source and target files
      convertctrl.SourceFile = inFile;
      convertctrl.TargetFile = outFile;

      // show preview
      convertctrl.Preview = true;

      // convert it now!
      convertctrl.StartConvert();
   }
   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 (convertctrl.State == ConvertState.Running)
      Application.DoEvents();
}

public void ConvertCtrl_ErrorAbort(object sender, ErrorAbortEventArgs e)
{
   // uncomment this line to show the error message
   // MessageBox.Show(e.errorMessage, "Convert Error");

   // set result
   _result = true;
}

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

Target Platforms

See Also

Reference

ConvertCtrl Class
ConvertCtrl Members

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.

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