How can I play a wav-file from memory or blob-field?

Source: Internet
Author: User

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.