Scalabium Software

SMReport Autogenerated
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;


Published: July 17, 2000

See also
 
Excel Reader (dll)
ABA Picture Convert
SMDBGrid
dBase Viewer
Paradox Password Recovery
Paradox to MS Access converter
Database Information Manager
Fast Document Viewer
SMReport
Protected Storage Viewer
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2022, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport/SMImport suites