S
shenbo_shenbo
Unregistered / Unconfirmed
GUEST, unregistred user!
一个对讲程序,想在对讲时把通话录下来,对讲程序已经成功,但录音录完成后播放不了,大致的程序如下,请朋友们帮帮忙看看,怎样解决录音的问题,谢谢!
procedure TForm1.FormCreate(Sender: TObject);
begin
FFileStrm := TFileStream.Create(ExtractFilePath(Application.ExeName) + 'Temp.wav', fmOpenReadWrite);
//创建录音文件流
end;
procedure TForm1.SocketWaveInData(data: Pointer;
size: Integer);
//对话发起方
var
buf: array of Char;
i: Integer;
begin
SetLength(buf, Size);
Move(Data^, PChar(buf)^, Size);
ClientSocket.Socket.SendBuf(PChar(buf)^, Size);
//发送通话内容
end;
procedure TForm1.ServerSocketClientRead(Sender: TObject;
Socket: TCustomWinSocket);
对话接收方
var
Size: Integer;
P: PChar;
begin
Size := Socket.ReceiveLength;
GetMem(P, Size);
Socket.ReceiveBuf(P^, Size);
//在此处写录音程序,下面的这句话能写入文件,但文件的录音放不出,请帮帮忙问题的所在
FFileStrm.WriteBuffer(P^, Size);
SocketWaveOut.PlayBack(P, Size);
FreeMem(P, Size);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FFileStrm := TFileStream.Create(ExtractFilePath(Application.ExeName) + 'Temp.wav', fmOpenReadWrite);
//创建录音文件流
end;
procedure TForm1.SocketWaveInData(data: Pointer;
size: Integer);
//对话发起方
var
buf: array of Char;
i: Integer;
begin
SetLength(buf, Size);
Move(Data^, PChar(buf)^, Size);
ClientSocket.Socket.SendBuf(PChar(buf)^, Size);
//发送通话内容
end;
procedure TForm1.ServerSocketClientRead(Sender: TObject;
Socket: TCustomWinSocket);
对话接收方
var
Size: Integer;
P: PChar;
begin
Size := Socket.ReceiveLength;
GetMem(P, Size);
Socket.ReceiveBuf(P^, Size);
//在此处写录音程序,下面的这句话能写入文件,但文件的录音放不出,请帮帮忙问题的所在
FFileStrm.WriteBuffer(P^, Size);
SocketWaveOut.PlayBack(P, Size);
FreeMem(P, Size);
end;