Page 1 of 1

Exception in StockAudioPlayer.PlayStream

PostPosted: April 7th, 2012, 7:19 pm
by ArturAs
Where is my mistake? error in msvcrt.dll

This doesn't work: (Click Button1, then Button2)

Code: Select all
procedure TFmMain.Button1Click(Sender: TObject);
begin
  if stream = nil then
    stream := TMemoryStream.Create;
  StockAudioRecorder.RecordToStream( stream );
end;

procedure TFmMain.Button2Click(Sender: TObject);
begin
  if StockAudioPlayer.Active then
    StockAudioPlayer.Active := False
  else
    StockAudioRecorder.Active := False;
  StockAudioPlayer.PlayStream( Stream);
end;


This does: (Click Button1, then ButtonStop, then Button2)
===============================================
Code: Select all
procedure TFmMain.Button1Click(Sender: TObject);
begin
  if stream = nil then
    stream := TMemoryStream.Create;
  StockAudioRecorder.RecordToStream( stream )
end;

procedure TFmMain.Button2Click(Sender: TObject);
begin
  StockAudioPlayer.PlayStream( Stream);
end;

procedure TFmMain.ButtonStopClick(Sender: TObject);
begin
  if StockAudioPlayer.Active then
    StockAudioPlayer.Active := False
  else
    StockAudioRecorder.Active := False;
end;

Thanks
Artur

Re: Exception in StockAudioPlayer.PlayStream

PostPosted: May 9th, 2012, 12:30 am
by Kambiz
In asynchronous mode you should wait for the stop action (active := false) to be completed.