filestorage Playing .WAVs (example)
acFileStorage component
Return to Introduction  Previous page  Next page
Following code demonstrates how to access stored files at run-time without extracting them to hard disk. This sample shows how to play stored .WAV file.

Delphi:



uses MMSystem;  
 
procedure TForm1.Button1Click(Sender: TObject);  
var  
  StoredFile: TStoredFile;  
  Data: TMemoryStream;  
begin  
  StoredFile := FileStorage1.Files[0];  
  Data := StoredFile.Data;  
 
  // the stored data could be retrieved from Data.Memory  
  sndPlaySound(Data.Memory, SND_MEMORY or SND_ASYNC);  
end;  


C++ Builder:


#include <mmsystem.h>  
 
void __fastcall TForm1::Button1Click(TObject *Sender)  
{  
  TStoredFile *StoredFile = (TStoredFile*)acFileStorage1->Files->Items[0];  
  TMemoryStream *Data = StoredFile->Data;  
 
  // the stored data could be retrieved from Data->Memory  
  sndPlaySound((LPCTSTR)Data->Memory, SND_MEMORY|SND_ASYNC);  
}