My Second Convert (Visual FoxPro 6.0)

The ltmmConvertCtrl object allows the user to recompress multimedia files or convert from one multimedia format to another. Using the following steps:

1.

Start with the form that you created in My First Convert.

2.

Add 2 combo boxes to you form. Name them cbVideoComp and cbAudioComp, respectively and change their Style property to 2 (Drop Down List)

3.

Update the Form Init procedure as follows:

&& Define the source file. 
ThisForm.ltmmConvertCtrl1.SourceFile = "c:\source.avi"
&& Define the Target or output file. 
ThisForm.ltmmConvertCtrl1.TargetFile = "c:\target.avi"
&& Enumerate the Video Compressors. 
With ThisForm.cbVideoComp
   .AddItem("No Recompression")
   && set the item data to -1 to use it when we will set the Selection Property. 
   .ItemData(.NewIndex) = -1

   count = ThisForm.ltmmConvertCtrl1.VideoCompressors.Count
   If count > 0 Then
      For i = 0 To count - 1
         .AddItem(ThisForm.ltmmConvertCtrl1.VideoCompressors.Item (i) .FriendlyName
         .ItemData(.NewIndex) = i
      Next
   EndIf
EndWith

&& Enumerate the Audio Compressors. 
With ThisForm.cbAudioComp
   .AddItem("No Recompression")
   && set the item data to -1 to use it when we will set the Selection Property. 
   .ItemData(.NewIndex) = -1

   count = ThisForm.ltmmConvertCtrl1.AudioCompressors.Count
   If count > 0 Then
      For i = 0 To count - 1
         .AddItem(ThisForm.ltmmConvertCtrl1.AudioCompressors.Item (i) .FriendlyName
         .ItemData(.NewIndex) = i
      Next
   EndIf
EndWith
ThisForm.UpdateComboStatus()

4.

Code the cbVideoComp Click procedure as follows.

ThisForm.MousePointer = 11 && Hourglass
ThisForm.ltmmConvertCtrl1.VideoCompressors.Selection = ThisForm.cbVideoComp.ItemData(ThisForm.cbVideoComp.ListIndex) 
ThisForm.MousePointer = 0 && Default
Thisform.UpdateComboStatus()

5.

Code the cbAudioComp Click procedure as follows.

ThisForm.MousePointer = 11 && Hourglass
ThisForm.ltmmConvertCtrl1.AudioCompressors.Selection = ThisForm.cbAudioComp.ItemData(ThisForm.cbAudioComp.ListIndex) 
ThisForm.MousePointer = 0 && Default
Thisform.UpdateComboStatus()

6.

On the Form menu, select New Method. Name the new method UpdateComboStatus and code its procedure as follows:

&& Video compressors
compressors = ThisForm.ltmmConvertCtrl1.VideoCompressors
index = compressors.Selection
With ThisForm.cbVideoComp
   For i = 1 to .ListCount do
      If .ItemData(i) = index Then
         .ListIndex = i
         Exit && For
      EndIf
   Next
EndWith

&& Audio compressors
compressors = ThisForm.ltmmConvertCtrl1.AudioCompressors
index = compressors.Selection
With ThisForm.cbAudioComp
   For i = 1 to .ListCount do
      If .ItemData(i) = index Then
         .ListIndex = i
         Exit && For
      EndIf
   Next
EndWith

7.

Code the ltmmConvertCtrl1 Complete procedure as follows.

&& indicate that the conversion has completed
ThisForm.Caption = "Conversion completed." 

8.

Code the ltmmConvertCtrl1 ErrorAbort procedure as follows.

LPARAMETERS errorcode
&& indicate that a conversion error has occurred
ThisForm.Caption = "Error " + Str(ErrorCode) + ". Conversion aborted." 

9.

Code the ltmmConvertCtrl1 Progress procedure as follows.

LPARAMETERS percent
&& update the percentage text
ThisForm.Caption = Str(Percent) + "%"

10.

Code the ltmmConvertCtrl1 Started procedure as follows.

ThisForm.Caption = "Started"

11.

Run your program to test it.