Форум: "Media";
Текущий архив: 2006.03.12;
Скачать: [xml.tar.bz2];
ВнизКак программно сделать mute Найти похожие ветки
← →
alsov © (2005-10-01 19:29) [0]Приветствую, Мастера
Подскажите код как программно сделать mute(вуключить/включить звук)
Надо чтобы работал на всех виндах
Нашел код, но он работает только пож хп
unit uMute;
interface
uses
MMSystem, Windows, SysUtils;
function GetMasterMute(Mixer: hMixerObj; var Control: TMixerControl): MMResult;
procedure SetMasterMuteValue(Mixer: hMixerObj; Value: Boolean);
implementation
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", [0]);
end;
end.
Спасибо за любую помощь
← →
S@shka © (2005-10-01 20:00) [1]www.torry.net
← →
alsov © (2005-10-01 20:37) [2]Вот так вроде заработало
function InvertMasterMute: Boolean;
var
MH: HMixer;
ML: TMixerLine;
MLCS: TMixerLineControls;
MLC: TMixerControl;
MCD: TMixerControlDetails;
MCDU: TMixerControlDetails_Unsigned;
begin
Result := False;
if mixerOpen(@MH, 0, 0, 0, 0) = MMSYSERR_NOERROR then
begin
ML.cbStruct := SizeOf(TMixerLine);
ML.dwComponentType := MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
if mixerGetLineInfo(MH, @ML, MIXER_OBJECTF_HMIXER or
MIXER_GETLINEINFOF_COMPONENTTYPE) = MMSYSERR_NOERROR then
begin
MLCS.cbStruct := SizeOf(TMixerLineControls);
MLCS.cbmxctrl := SizeOf(TMixerControl);
MLCS.dwLineID := ML.dwLineID;
MLCS.dwControlType := MIXERCONTROL_CONTROLTYPE_MUTE;
MLCS.cControls := 1;
MLCS.pamxctrl := @MLC;
if (mixerGetLineControls(MH, @MLCS, MIXER_OBJECTF_HMIXER or
MIXER_GETLINECONTROLSF_ONEBYTYPE) = MMSYSERR_NOERROR) then
begin
MCD.cbStruct := SizeOf(TMixerControlDetails);
MCD.dwControlID := MLC.dwControlID;
MCD.cChannels := 1;
MCD.cMultipleItems := 0;
MCD.cbDetails := SizeOf(TMixerControlDetails_Unsigned);
MCD.paDetails := @MCDU;
if mixerGetControlDetails(MH, @MCD, 0) = MMSYSERR_NOERROR then
begin
if MCDU.dwValue = 0
then MCDU.dwValue := 1
else MCDU.dwValue := 0;
Result := (mixerSetControlDetails(MH, @MCD, 0) = MMSYSERR_NOERROR);
end;
end;
end;
end;
end;
Страницы: 1 вся ветка
Форум: "Media";
Текущий архив: 2006.03.12;
Скачать: [xml.tar.bz2];
Память: 0.46 MB
Время: 0.013 c