Mega Code Archive

 
Categories / Delphi / Multimedia
 

Muting and revoicing the audio from your application

Title: Muting and revoicing the audio from your application. Question: 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! WARNING: you must avoid pressing 2 times the mute button or the mixer data will be lost. so I added a boolean condition. Answer: Uses MMSystem; (...) (Global variables) Var MyVolume : Array[ 0..10 ] Of LongInt; mDevs : Integer; IsMute : Boolean; Create two button: 1. cmdMute 2. cmdRevoice Procedure TfrmMain.FormCreate( Sender : TObject ); Begin IsMute := False; End; Procedure TfrmMain.cmdMuteClick( Sender : TObject ); Var I : Integer; Begin If ( Not( IsMute ) ) Then Begin mDevs := auxGetNumDevs; For I := 0 To mDevs Do Begin auxGetVolume( I, Addr( MyVolume[ I ] ) ); auxSetVolume( I, LongInt( 9000 ) * 65536 + LongInt( 9000 ) ); End; IsMute := True; End; End; Procedure TfrmMain.cmdRevoiceClick( Sender : TObject ); Var I : Integer; Begin If ( IsMute ) Then Begin For I := 0 To mDevs Do auxSetVolute( I, MyVolume[ I ] ); IsMute := False; End; End;