Winapi: sndplaysound-play wav files

Source: Internet
Author: User
// Declaration: sndplaysound (lpszsoundname: pchar; {sound file} uflags: uint {playback options}): bool; // optional value of the uflags parameter: snd_sync = 0; {synchronous playback, the program must wait until the playback is complete before executing} snd_async = 1; {asynchronous playback. After the function returns, the program starts playing. The program continues to be executed.} snd_nodefault = 2; {when the sound file is missing, the function automatically returns the default sound that is not played.} snd_memory = 4; {the sound in the player memory, for example, the sound in the resource file} snd_loop = 8; {loop playback, need to be combined with snd_async} snd_nostop = 16; {if the current playing sound is in progress, false is returned immediately}
 // Example: Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) button1: tbutton; button2: tbutton; button3: tbutton; Procedure button1click (Sender: tobject); Procedure destroy (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses mmsystem; {sndplaysound declaration in this unit} const S = 'C: \ windows \ media \ Windows XP start .wav '; // play procedure tform1.button1click (Sender: tobject) synchronously ); begin sndplaysound (S, snd_sync); beep; {this sentence will be executed after playing} end; // procedure tform1.button2click (Sender: tobject); begin sndplaysound (S, snd_async); beep; {this sentence will be executed immediately} end; // play procedure tform1.button3click (Sender: tobject); begin sndplaysound (S, snd_loop or snd_async); end.
 // Sndplaysound can also be used to play audio files in resources or memory. For example:

Http://www.cnblogs.com/del/archive/2008/02/15/1069523.html

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.