unit1.pas
来自「this is my first program in delphi」· PAS 代码 · 共 54 行
PAS
54 行
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MPlayer, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
MediaPlayer1: TMediaPlayer;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.Hide; {This hides the warning lablel that I put on the form}
MediaPlayer1.Hide; {This hides the media player component, since it's only
needed to play a sound when the button is pressed}
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
MediaPlayer1.FileName := 'TechRap.mid'; {Points to the file, techrap.mid}
{If the file is not on the target computer, then it will
not play the way it should. If the file is not in the
same directory as the application, then the full
pathname will be needed to play the sound}
MediaPlayer1.Open; {Opens the file that's been pointed to}
MediaPlayer1.Wait := True; {Tells the program to wait before closing
the sound. Without this, the program would not wait to stop
the sound and the sound would be stopped just after it was
opened}
MediaPlayer1.Play; {Plays the file, this will work with media
files with any microsoft based extention like mov and wav
but not with other extentions like ram and mod}
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?