Author: Christian Cristofori
Based on an old article that described the solution for muting the audio during my
application, someone asked me to make a similar to be controlled from a Button:
here's the solution... easy and fast!
Answer:
WARNING: you must avoid pressing 2 times the mute button or the mixer data will be
lost. so I added a boolean condition.
1 uses2 MMSystem;
3 4 {...}5 6 {Global variables}7 8 var9 MyVolume: array[0..10] of LongInt;
10 mDevs: Integer;
11 IsMute: Boolean;
12 13 Create two button:
14 15 cmdMute
16 cmdRevoice
17 18 procedure TfrmMain.FormCreate(Sender: TObject);
19 begin20 IsMute := False;
21 end;
22 23 procedure TfrmMain.cmdMuteClick(Sender: TObject);
24 var25 I: Integer;
26 begin27 if (not (IsMute)) then28 begin29 mDevs := auxGetNumDevs;
30 for I := 0 to mDevs do31 begin32 auxGetVolume(I, Addr(MyVolume[I]));
33 auxSetVolume(I, LongInt(9000) * 65536 + LongInt(9000));
34 end;
35 IsMute := True;
36 end;
37 end;
38 39 procedure TfrmMain.cmdRevoiceClick(Sender: TObject);
40 var41 I: Integer;
42 begin43 if (IsMute) then44 begin45 for I := 0 to mDevs do46 auxSetVolute(I, MyVolume[I]);
47 IsMute := False;
48 end;
49 end;