Home > Back-end >  Implore you ~ weak weak ask a Delphi about database, extract and play
Implore you ~ weak weak ask a Delphi about database, extract and play

Time:10-02

Procedure TForm1. Button1Click (Sender: TObject);
Var
St: tmemorystream;
The begin
Aq1. SQL. Text:='select id, wav from wen where id=1'.
Aq1. Active:=true;

If aq1. FieldValues [' id ']=null then aq1. Insert the else aq1. Edit;

St:=tmemorystream. Create;
St. The Clear;
St. LoadFromFile (ExtractFilePath (paramstr (0)) + '1. Wav');

Tblobfield (Aq1 FieldByName (' wav). LoadFromStream (st);//write audio stream to the database

St. Free;
Aq1. Post;
end;


Procedure TForm1. Button2Click (Sender: TObject);
Var
St: tmemorystream;
The begin
St:=tmemorystream. Create;//
St. The Clear;
Aq1. SQL. Text:='select wav from wen where id=1'.
Aq1. Active:=true;

Tblobfield (Aq1 FieldByName (' wav). SaveToStream (st);//read the audio data to flow

//my question here to start -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Sndplaysound (pchar (st), SND_MEMORY and SND_ASYNC);

//how to play? How do you play? How do you play? It's driving me crazy!!!!!!
//don't write to the temporary file, of course, in the memory can also play in other methods, please!!!!!!
//end of my problem, thank you -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
St. Free;
end;

CodePudding user response:

Only a little advice, pchar (st) this usage is the building of her own, don't feel strange

CodePudding user response:

Yes yes, the problem is here, how can I describe st pointer?

CodePudding user response:

Char (st) a try?

CodePudding user response:

//reference
Var hFind hRes: THandle;
Song: PChar;
The begin
HFind:=FindResource (HLib, PChar (SoundName), 'WAVE');
If (hFind & lt;> 0) then the begin
HRes:=LoadResource (HLib hFind);
If (hRes & lt;> 0) then the begin
Song:=LockResource (hRes);
If Assigned (Song) then SndPlaySound (Song, snd_ASync or snd_Memory);
UnlockResource (hRes);
end;
FreeResource (hFind);
end;

CodePudding user response:

refer to the second floor killerfriend response:
yes, yes, the problem is here, how can I describe st pointer?

Pchar (st. Memory)

CodePudding user response:

reference 4 floor sailxia response:
for reference//
Var hFind hRes: THandle;
Song: PChar;
The begin
HFind:=FindResource (HLib, PChar (SoundName), 'WAVE');
If (hFind & lt;> 0) then the begin
HRes:=LoadResource (HLib hFind);
If (hRes & lt;> 0) then the begin
Song:=LockResource (hRes);
If Assigned (Song) then SndPlaySound (Song, snd_ASync or snd_Memory);
UnlockResource (hRes);
end;
FreeResource (hFind);
end;

CodePudding user response:

Playback file does not have to,
Tblobfield (Aq1 FieldByName (' wav). SaveTofile (' d: \ aleem walji av);


PlaySound (' d: \ aleem walji av, 0, SND_ASYNC);
  • Related