Use Delphi design to circulate sound file program

Source: Internet
Author: User

This example shows how to play a specified sound file in a loop while the program is running.

First add the MMSystem to the uses section of the program, and then add the following code during the initialization of the form:

procedure TForm1.FormCreate(Sender: TObject);
begin
 SndPlaySound(’c:\RECYCLE.WAV’,SND_ASYNC or SND_LOOP);
end;

In this way, at the beginning of the program operation, the program will continue to play the sound file C:\RECYCLE through the sndPlaySound function loop. Wav.

The program code is as follows:

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MMSYSTEM;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
 { Private declarations }
public
 { Public declarations }
end;
var
 Form1: TForm1;
 implementation
 {$R *.dfm}
 procedure TForm1.FormCreate(Sender: TObject);
begin
 SndPlaySound(’c:\RECYCLE.WAV’,SND_ASYNC or SND_LOOP);
end;
end.

Save the file, and then press the F9 key to run the program. The program will play the sound file uninterrupted during the program's operation.

By calling the sndPlaySound function, the reader can play the sound file in his or her own program, but if you specify a parameter Snd_loop, you can loop through the sound file.

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.