Como reproduzir som pelo alto-falante interno?
Como faço para o delphi reproduzir arquivos de som (wav,mp3,ogg...)
pelo alto-falante que fica dentro do gabinete?
[b:404010a117]Título editado pelo Moderador (AZ)[/b:404010a117]
pelo alto-falante que fica dentro do gabinete?
[b:404010a117]Título editado pelo Moderador (AZ)[/b:404010a117]
Coelhopirado
Curtidas 0
Respostas
Carlosk
30/10/2003
isso eh impossivel...
GOSTEI 0
Rodrigo_rcp
30/10/2003
Isso é o melhor que eu vi e não esta nem perto do que você quer
procedure SetPort(address, Value: Word);
var
bValue: Byte;
begin
bValue := trunc(Value and 255);
asm
mov dx, address
mov al, bValue
out dx, al
end;
end;
function GetPort(address: Word): Word;
var
bValue: Byte;
begin
asm
mov dx, address
in al, dx
mov bValue, al
end;
GetPort := bValue;
end;
procedure Sound(aFreq, aDelay: Integer);
procedure DoSound(Freq: Word);
var
B: Byte;
begin
if Freq > 18 then
begin
Freq := Word(1193181 div Longint(Freq));
B := Byte(GetPort($61));
if (B and 3) = 0 then
begin
SetPort($61, Word(B or 3));
SetPort($43, $B6);
end;
SetPort($42, Freq);
SetPort($42, Freq shr 8);
end;
end;
procedure Delay(MSecs: Integer);
var
FirstTickCount: LongInt;
begin
FirstTickCount := GetTickCount;
repeat
Sleep(1);
until ((GetTickCount - FirstTickCount) >= Longint(MSecs));
end;
begin
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
Windows.Beep(aFreq, aDelay);
end
else
begin
DoSound(aFreq);
Delay(aDelay);
end;
end;
procedure NoSound;
var
Value: Word;
begin
if not (Win32Platform = VER_PLATFORM_WIN32_NT) then
begin
Value := GetPort($61) and $FC;
SetPort($61, Value);
end;
end;
Exemplo de uso:
CODE
procedure TForm1.Button1Click(Sender: TObject);
begin
Sound(500, 1000);
Sound(700, 1000);
Sound(900, 1000);
NoSound;
end;
GOSTEI 0
Bisao
30/10/2003
Ola blz, tenta isso aki:
procedure TForm1.Button2Click(Sender: TObject);
var
rStream: TResourceStream;
fStream: TFileStream;
fname: string;
begin
{this part extracts the mp3 from exe}
fname:=ExtractFileDir(Paramstr(0))+´Intro.mp3´;
rStream := TResourceStream.Create
(hInstance, ´Intro´, RT_RCDATA);
try
fStream := TFileStream.Create(fname, fmCreate);
try
fStream.CopyFrom(rStream, 0);
finally
fStream.Free;
end;
finally
rStream.Free;
end;
{this part plays the mp3}
MediaPlayer1.Close;
MediaPlayer1.FileName:=fname;
MediaPlayer1.Open;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
rStream: TResourceStream;
fStream: TFileStream;
fname: string;
begin
{this part extracts the mp3 from exe}
fname:=ExtractFileDir(Paramstr(0))+´Intro.mp3´;
rStream := TResourceStream.Create
(hInstance, ´Intro´, RT_RCDATA);
try
fStream := TFileStream.Create(fname, fmCreate);
try
fStream.CopyFrom(rStream, 0);
finally
fStream.Free;
end;
finally
rStream.Free;
end;
{this part plays the mp3}
MediaPlayer1.Close;
MediaPlayer1.FileName:=fname;
MediaPlayer1.Open;
end;
GOSTEI 0