在delphi5.0中如何使用api循环播放midi音乐,avi动画? mediaplayer就可以循环播放呀,而且功能很强大 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下面是源代码:unit Unit1;interfaceusesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,MPlayer, StdCtrls;typeTForm1 = class(TForm)MediaPlayer1: TMediaPlayer;Button1: TButton;OpenDialog1: TOpenDialog;procedure MediaPlayer1Notify(Sender: TObject);procedure MediaPlayer1Click(Sender: TObject; Button: TMPBtnType;var DoDefault: Boolean);procedure Button1Click(Sender: TObject);private{ Private declarations }public{ Public declarations }end;varForm1: TForm1;implementation{$R *.DFM}procedure TForm1.MediaPlayer1Notify(Sender: TObject);begin with MediaPlayer1 do begin if Notify and //接受信息 (mode=mpStopped) then//已经停止 begin ReWind; play; end; notify:=true;//开始接受信息end;end;procedure TForm1.MediaPlayer1Click(Sender: TObject; Button: TMPBtnType;var DoDefault: Boolean);begin if (Button=btStop) or (Button=btPause) then MediaPlayer1.Notify:=falseelse MediaPlayer1.Notify:=true; end;procedure TForm1.Button1Click(Sender: TObject);begin if OpenDialog1.Execute then with MediaPlayer1 do begin fileName:=OpenDialog1.FileName;notify:=true;try open; play;except raise exception.Create('打开文件时出错');end;caption:='循环播放演示-->'+fileName;end;end;end.窗体As text代码 object Form1: TForm1Left = 195Top = 107Width = 378Height = 182Caption = '循环播放演示'Color = clBtnFaceFont.Charset = DEFAULT_CHARSETFont.Color = clWindowTextFont.Height = -11Font.Name = 'MS Sans Serif'Font.Style = []OldCreateOrder = FalsePixelsPerInch = 96TextHeight = 13object MediaPlayer1: TMediaPlayerLeft = 24Top = 16Width = 298Height = 33TabOrder = 0OnClick = MediaPlayer1ClickOnNotify = MediaPlayer1Notifyendobject Button1: TButtonLeft = 193Top = 104Width = 129Height = 33Caption = '打开...'Default = TrueTabOrder = 1OnClick = Button1Clickendobject OpenDialog1: TOpenDialogTitle = '打开音乐文件'Left = 294Top = 32endend////////////////////////////////////////////////////if FileExists(ExtractFilePath(Application.Exename)+'RunLib\T01.AVI') then begin MediaPlayer1.FileName:=(ExtractFilePath(Application.Exename)+'RunLib\T01.AVI'); MediaPlayer1.Open; MediaPlayer1.Notify:=true; MediaPlayer1.Display:=Form2; MediaPlayer1.DisplayRect:=Form2.ClientRect; MediaPlayer1.Play; end;然后如下让它循环procedure TForm2.MediaPlayer1Notify(Sender: TObject);begin if MCIStop=1 then Exit; if MediaPlayer1.Mode=mpStopped then begin MediaPlayer1.Rewind; MediaPlayer1.Play; end; MediaPlayer1.Notify:=true;end; keybd_event 模似键盘, 怎么打中文 如何检测当前电脑的分辨率是多少? 【求助】关于ServerSocket的问题.. 谁能给个李维的《delphi7高效数据库设计》的下载地址?? 怎么样把二进制数据转化为十进制数据?急!!!!! 不想把代码写在MS-SQL的存储过程内,用DELPHI内的ADOquery 执行代码,但是同样的参数,要重复很多遍,如, delphi的最新补丁是什么 两个画面如何连接? 关于动态创建控件的问题在(mdi中) 涨价了! 如何加密或crc校验一个.dbf? 控制光驱
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
MPlayer, StdCtrls;type
TForm1 = class(TForm)
MediaPlayer1: TMediaPlayer;
Button1: TButton;
OpenDialog1: TOpenDialog;
procedure MediaPlayer1Notify(Sender: TObject);
procedure MediaPlayer1Click(Sender: TObject; Button: TMPBtnType;
var DoDefault: Boolean);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.MediaPlayer1Notify(Sender: TObject);
begin
with MediaPlayer1 do
begin
if Notify and //接受信息
(mode=mpStopped) then//已经停止
begin
ReWind;
play;
end;
notify:=true;//开始接受信息
end;end;procedure TForm1.MediaPlayer1Click(Sender: TObject; Button: TMPBtnType;
var DoDefault: Boolean);
begin
if (Button=btStop) or (Button=btPause) then
MediaPlayer1.Notify:=false
else
MediaPlayer1.Notify:=true;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
with MediaPlayer1 do
begin
fileName:=OpenDialog1.FileName;
notify:=true;
try
open;
play;
except
raise exception.Create('打开文件时出错');
end;
caption:='循环播放演示-->'+fileName;
end;
end;end.
窗体As text代码
object Form1: TForm1
Left = 195
Top = 107
Width = 378
Height = 182
Caption = '循环播放演示'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object MediaPlayer1: TMediaPlayer
Left = 24
Top = 16
Width = 298
Height = 33
TabOrder = 0
OnClick = MediaPlayer1Click
OnNotify = MediaPlayer1Notify
end
object Button1: TButton
Left = 193
Top = 104
Width = 129
Height = 33
Caption = '打开...'
Default = True
TabOrder = 1
OnClick = Button1Click
end
object OpenDialog1: TOpenDialog
Title = '打开音乐文件'
Left = 294
Top = 32
end
end
////////////////////////////////////////////////////if FileExists(ExtractFilePath(Application.Exename)+'RunLib\T01.AVI') then
begin
MediaPlayer1.FileName:=(ExtractFilePath(Application.Exename)+'RunLib\T01.AVI');
MediaPlayer1.Open;
MediaPlayer1.Notify:=true;
MediaPlayer1.Display:=Form2;
MediaPlayer1.DisplayRect:=Form2.ClientRect;
MediaPlayer1.Play;
end;然后如下让它循环
procedure TForm2.MediaPlayer1Notify(Sender: TObject);
begin
if MCIStop=1 then Exit;
if MediaPlayer1.Mode=mpStopped then
begin
MediaPlayer1.Rewind;
MediaPlayer1.Play;
end;
MediaPlayer1.Notify:=true;
end;