Directly Access the DirectShow Objects (Delphi 6.0)
The ltmmCaptureCtrl, ltmmConvertCtrl, and ltmmPlayCtrl objects implement the GetSubObject method to allow the user the ability to gain access to DirectShow specific objects.
1. |
Start Delphi 6. | |
2. |
If you didn’t install LEAD Multi-Media controls before, install them. On the Component pull-down menu, use the Import ActiveX Control… and select the LEAD Multi-Media Library (14), and Press install, and then compile and install the package dclusr.dpk. | |
3. |
From the ActiveX controls tab; add the ltmmPlayCtrl to your form. | |
4. |
If you didn’t import LEAD Audio VUMeter Filter Library before, import it. On the Project pull-down menu, use the Import Type library… . In case you can’t find "LEAD Audio VUMeter Filter Library" in the list, press the Add button and browse to find and choose the library "LMAVUMeter.dll", and press the Open button to close the "Open Type library" dialog box. Select the LEAD Audio VUMeter Filter Library, and Press install, and then compile and install the package dclusr.dpk. | |
5. |
Add a button control to your form, and name it as follows: | |
|
Name |
Caption |
|
btnGetVUMeterFilter |
Get VUMeter filter |
6. |
Handle the btnGetVUMeterFilter Click event, and code btnGetVUMeterFilterClick Procedure as follows |
procedure TForm1.btnGetVUMeterFilterClick(Sender: TObject);
var
index: Integer;
vumeter: LMAVUMeter;
LeftLevel: Integer; // Left level
RightLevel: Integer; // Right Level
begin
// Get the index of the VUMeter filter.
index:= ltmmPlayCtrl1.AudioProcessors.Find('@device:sw:{5FFE757A-509A-477E-A1F1-68812010A6DD}\{E2B7DB5C-38C5-11D5-91F6-00104BDB8FF9}');
// Select the VUMeter Filter
ltmmPlayCtrl1.SelectedAudioProcessors.Add ( ltmmPlayCtrl1.AudioProcessors.Item (index), 0 ) ;
// Get the VUMeter Filter
vumeter:= LMAVUMeter(ltmmPlayCtrl1.GetSubObject(ltmmPlay_Object_SelAudioProcessor));
// read the left channel power
LeftLevel:= vumeter.LeftLevel;
// read the right channel power
RightLevel:= vumeter.RightLevel;
// Display the and the right level values
ShowMessage ( 'Left Level =' + IntToStr(LeftLevel) + Chr(13) + 'Right Level =' + IntToStr(RightLevel) );
end;
7. |
Run your program to test it. |