Scalabium Software

SMExport advertising

Knowledge for your independence.
Home Delphi and C++Builder tips



#91:How can I play a wav-file from memory or BLOB-field?

Sometimes you needs to play a some sounds from own app but store these sounds in BLOB-field of table or in some external files.

To play a wav-file you must call the PlaySound procedure which have the few parameters - sound (which you want to play), handle of file with resource (only for wav from exe/dll-file) and flags for playing.

For example, if you want to play a wav from BLOB, you can use the next code:

var
  b: TBlobStream;
  m: TMemoryStream;
begin
  b := TBlobStream.Create(yourTable, bmRead);
  try
    m := TMemoryStream.Create;
    try
      {copy a wav from BLOB into memory}
      m.CopyFrom(b, b.Size);

      {Play it but if we'll have an error, raise exception}
      Win32Check(PlaySound(m.Memory, 0, SND_SYNC or SND_MEMORY));
    finally
      m.Free
    end;
  finally
    b.Free
  end;
end;
See also
 
SMExport suite
SMImport suite
SMReport
SMDBGrid
MAPIMail
Paradox Viewer
Paradox ActiveX
ExcelFile Viewer
Metafile Convert
DBLoad
DBExport tools
 
 
Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyrightc 1998-2008, Scalabium Software. All rights reserved.
webmaster@scalabium.com

July 17, 2000

SMReport Autogenerated