Hey
ich hab nun was gefunden um die laütstarke zu regeln. Allerdings mit 10 TButtons von 100%-10% und eine checkbox für mute. Funktioniert sehr gut.
nun bin ich noch an der suche für einen equalizer und eine Visualisierung wie bei Windows Media Player(Streifen und Wellen/streifen). kann mir jemand helfen?
der Code für Die lautstärke mit 10TButtons
Delphi-Quellcode:
const
MCI_SETAUDIO = $0873;
MCI_DGV_SETAUDIO_VOLUME = $4002;
MCI_DGV_SETAUDIO_ITEM = $00800000;
MCI_DGV_SETAUDIO_VALUE = $01000000;
MCI_DGV_STATUS_VOLUME = $4019;
type
MCI_DGV_SETAUDIO_PARMS = record
dwCallback: DWORD;
dwItem: DWORD;
dwValue: DWORD;
dwOver: DWORD;
lpstrAlgorithm: PChar;
lpstrQuality: PChar;
end;
type
MCI_STATUS_PARMS = record
dwCallback: DWORD;
dwReturn: DWORD;
dwItem: DWORD;
dwTrack: DWORD;
end;
procedure SetMPVolume(MP: TMediaPlayer; Volume: Integer);
{ Volume: 0 - 1000 }
var
p: MCI_DGV_SETAUDIO_PARMS;
begin
{ Volume: 0 - 1000 }
p.dwCallback := 0;
p.dwItem := MCI_DGV_SETAUDIO_VOLUME;
p.dwValue := Volume;
p.dwOver := 0;
p.lpstrAlgorithm := nil;
p.lpstrQuality := nil;
mciSendCommand(MP.DeviceID, MCI_SETAUDIO,
MCI_DGV_SETAUDIO_VALUE or MCI_DGV_SETAUDIO_ITEM, Cardinal(@p));
end;
function GetMPVolume(MP: TMediaPlayer): Integer;
var
p: MCI_STATUS_PARMS;
begin
p.dwCallback := 0;
p.dwItem := MCI_DGV_STATUS_VOLUME;
mciSendCommand(MP.DeviceID, MCI_STATUS, MCI_STATUS_ITEM, Cardinal(@p));
Result := p.dwReturn;
{ Volume: 0 - 1000 }
end;
procedure TMPForm.Button1Click(Sender: TObject);
begin
SetMPVolume(MediaPlayer1, 1000);
end;
procedure TMPForm.Button2Click(Sender: TObject);
begin
SetMPVolume(MediaPlayer1, 900);
end;
procedure TMPForm.Button3Click(Sender: TObject);
begin
SetMPVolume(MediaPlayer1, 800);
end;
procedure TMPForm.Button4Click(Sender: TObject);
begin
SetMPVolume(MediaPlayer1, 700);
end;
procedure TMPForm.Button5Click(Sender: TObject);
begin
SetMPVolume(MediaPlayer1, 600);
end;
procedure TMPForm.Button6Click(Sender: TObject);
begin
SetMPVolume(MediaPlayer1, 500);
end;
procedure TMPForm.Button7Click(Sender: TObject);
begin
SetMPVolume(MediaPlayer1, 400);
end;
procedure TMPForm.Button8Click(Sender: TObject);
begin
SetMPVolume(MediaPlayer1, 300);
end;
procedure TMPForm.Button9Click(Sender: TObject);
begin
SetMPVolume(MediaPlayer1, 200);
end;
procedure TMPForm.Button10Click(Sender: TObject);
begin
SetMPVolume(MediaPlayer1, 100);
end;
und hier der Code für Mute(Stumm)
[code=delphi]
function GetMasterMute(
Mixer: hMixerObj;
var Control: TMixerControl): MMResult;
// Returns True on success
var
Line: TMixerLine;
Controls: TMixerLineControls;
begin
ZeroMemory(@Line, SizeOf(Line));
Line.cbStruct := SizeOf(Line);
Line.dwComponentType := MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
Result := mixerGetLineInfo(Mixer, @Line,
MIXER_GETLINEINFOF_COMPONENTTYPE);
if Result = MMSYSERR_NOERROR then
begin
ZeroMemory(@Controls, SizeOf(Controls));
Controls.cbStruct := SizeOf(Controls);
Controls.dwLineID := Line.dwLineID;
Controls.cControls := 1;
Controls.dwControlType := MIXERCONTROL_CONTROLTYPE_MUTE;
Controls.cbmxctrl := SizeOf(Control);
Controls.pamxctrl := @Control;
Result := mixerGetLineControls(Mixer, @Controls,
MIXER_GETLINECONTROLSF_ONEBYTYPE);
end;
end;
procedure SetMasterMuteValue(
Mixer: hMixerObj;
Value: Boolean);
var
MasterMute: TMixerControl;
Details: TMixerControlDetails;
BoolDetails: TMixerControlDetailsBoolean;
Code: MMResult;
begin
Code := GetMasterMute(0, MasterMute);
if Code = MMSYSERR_NOERROR then
begin
with Details do
begin
cbStruct := SizeOf(Details);
dwControlID := MasterMute.dwControlID;
cChannels := 1;
cMultipleItems := 0;
cbDetails := SizeOf(BoolDetails);
paDetails := @BoolDetails;
end;
LongBool(BoolDetails.fValue) := Value;
Code := mixerSetControlDetails(0, @Details,
MIXER_SETCONTROLDETAILSF_VALUE);
end;
if Code <> MMSYSERR_NOERROR then
raise
Exception.CreateFmt('SetMasterMuteValue failure, '+
'multimedia system error #%d',
Code:
);
end;
procedure TMPForm.CheckBox1Click(Sender: TObject);
begin
SetMasterMuteValue(0, CheckBox1.Checked);
end;
MFG
MasterTobi