Главная страница | назад





Article #16918: Play an AVI file that has sound, silently

 Question and Answer Database
FAQ1918D.txt Play an AVI file that has sound, silently
Category :Miscellaneous
Platform :All
Product :All 32 bit
Question:
How can I play an AVI file that has sound silently without
adjusting the volume?
Answer:
The following example demonstrates playing an AVI file
silently by turning off the MCI audio channels in code.
Example:
uses MMSystem;
procedure SetMediaAudioOff(DeviceID : word);
var
SetParm : TMCI_SET_PARMS;
begin
SetParm.dwAudio := MCI_SET_AUDIO_ALL;
mciSendCommand(DeviceID,
MCI_SET,
MCI_SET_AUDIO or MCI_SET_OFF,
Longint(@SetParm));
end;
Procedure SetMediaAudioOn(DeviceID : word);
var
SetParm : TMCI_SET_PARMS;
begin
SetParm.dwAudio := MCI_SET_AUDIO_ALL;
mciSendCommand(DeviceID,
MCI_SET,
MCI_SET_AUDIO or MCI_SET_ON,
Longint(@SetParm));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
{Play AVI file silently}
MediaPlayer1.FileName := 'C:\TheWall\DELCAR2.AVI';
MediaPlayer1.Display := Panel1;
MediaPlayer1.Open;
MediaPlayer1.Play;
SetMediaAudioOff(MediaPlayer1.DeviceId);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
{Play AVI with sound}
MediaPlayer1.FileName := 'C:\TheWall\DELCAR2.AVI';
MediaPlayer1.Display := Panel1;
MediaPlayer1.Open;
MediaPlayer1.Play;
SetMediaAudioOn(MediaPlayer1.DeviceId);
end;
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99