Mirror

Enable and disable sound from your application (Views: 11)


Problem/Question/Abstract:

Ever needed to completely disable and then re-enable audio capabilities from your application? There's the way to simple do it.

Answer:

unit AudioCtrl;

interface

procedure EnableAudio;
procedure DisableAudio;

implementation

uses
  MMSystem;

var
  MyVolume: array[0..10] of LongInt;
  mDevs: Integer;

procedure EnableAudio;
var
  I: Integer;
begin
  for I := 0 to mDevs do
  begin
    auxSetVolume(I, MyVolume[I]);
  end;
end;

procedure DisableAudio;
var
  I: Integer;
begin
  mDevs := auxGetNumDevs;
  for I := 0 to mDevs do
  begin
    auxGetVolume(I, Addr(MyVolume[I]));
    auxSetVolume(I, LongInt(9000) * 65536 + LongInt(9000));
  end;
end;

end.

<< Back to main page