⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 this is my first program in delphi
💻 PAS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -