我的问题就是使用mciSendCommand如何获取当前播放音乐时间点,精度是毫秒。
回调事件如何捕捉,请高手指点,困惑了很久了。谢谢!代码如下unit mciPas;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,mmsystem, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
mciOpenParms: MCI_OPEN_PARMS;
m_MCIDeviceID: MCIDEVICEID;
mciPlayParms:MCI_PLAY_PARMS;
end;var
Form1: TForm1;implementation{$R *.dfm}//初始化参数
procedure TForm1.Button1Click(Sender: TObject);
VAR
file_name_: String;
begin
file_name_ := 'D:\test.wma';
mciOpenParms.lpstrDeviceType:='''';
mciOpenParms.lpstrElementName := PChar(file_name_);
mciSendCommand(0,MCI_OPEN,MCI_OPEN_ELEMENT,DWORD(@mciOpenParms));
m_MCIDeviceID := mciOpenParms.wDeviceID;
mciPlayParms.dwCallback := Handle;
mciPlayParms.dwFrom := 29*1000;
mciPlayParms.dwTo := mciPlayParms.dwFrom+1500;
end;//开始播放
procedure TForm1.Button2Click(Sender: TObject);
begin
mciSendCommand(m_MCIDeviceID,MCI_PLAY,MCI_FROM or MCI_TO or MCI_NOTIFY,integer(@mciPlayParms));
end;//如何获取到当前播放时间点
/*
windows sdk 说明The MCI_PLAY_PARMS structure contains positioning information for the MCI_PLAY command. typedef struct {
DWORD dwCallback;
DWORD dwFrom;
DWORD dwTo;
} MCI_PLAY_PARMS;
MembersdwCallbackThe low-order word specifies a window handle used for the MCI_NOTIFY flag.dwFromPosition to play from.dwToPosition to play to. ResWhen assigning data to the members of this structure, set the corresponding flags in the fdwCommand parameter of the mciSendCommand function to validate the members.
*/end.
回调事件如何捕捉,请高手指点,困惑了很久了。谢谢!代码如下unit mciPas;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,mmsystem, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
mciOpenParms: MCI_OPEN_PARMS;
m_MCIDeviceID: MCIDEVICEID;
mciPlayParms:MCI_PLAY_PARMS;
end;var
Form1: TForm1;implementation{$R *.dfm}//初始化参数
procedure TForm1.Button1Click(Sender: TObject);
VAR
file_name_: String;
begin
file_name_ := 'D:\test.wma';
mciOpenParms.lpstrDeviceType:='''';
mciOpenParms.lpstrElementName := PChar(file_name_);
mciSendCommand(0,MCI_OPEN,MCI_OPEN_ELEMENT,DWORD(@mciOpenParms));
m_MCIDeviceID := mciOpenParms.wDeviceID;
mciPlayParms.dwCallback := Handle;
mciPlayParms.dwFrom := 29*1000;
mciPlayParms.dwTo := mciPlayParms.dwFrom+1500;
end;//开始播放
procedure TForm1.Button2Click(Sender: TObject);
begin
mciSendCommand(m_MCIDeviceID,MCI_PLAY,MCI_FROM or MCI_TO or MCI_NOTIFY,integer(@mciPlayParms));
end;//如何获取到当前播放时间点
/*
windows sdk 说明The MCI_PLAY_PARMS structure contains positioning information for the MCI_PLAY command. typedef struct {
DWORD dwCallback;
DWORD dwFrom;
DWORD dwTo;
} MCI_PLAY_PARMS;
MembersdwCallbackThe low-order word specifies a window handle used for the MCI_NOTIFY flag.dwFromPosition to play from.dwToPosition to play to. ResWhen assigning data to the members of this structure, set the corresponding flags in the fdwCommand parameter of the mciSendCommand function to validate the members.
*/end.
解决方案 »
- 窗口不按指定参数就位
- ado 中 blob数据 字段 oldvalue 的问题
- 厚着脸皮来问这个问题,高手请进
- Types of actual and formal var parameters must be identical这个错误指什么?
- 如何直接将word文档存储到sql数据库,使用ole能不能办到?如何处理?急!!
- 我想打印Table中选中的一条的记录(有meno字段)如何实现?
- 过节了,技术大放送1:利用程序将WinHelp转换成HTML Help并在程序中轻松调用。
- ###哪位有透明或半透明的 Grid ListView TreeView 控件呀 ???
- 再请问...............(关于TeamSource)
- 运行状态时编辑控件
- 控制台中动态创建Webbrowser后获取源码
- Dll C函数转Delphi,变参总是返回nil, 请教!
private
{ Private declarations }
procedure MCINotify(Var Msg:TMessage);Message MM_MCINOTIFY;procedure TForm1.MCINotify(Var Msg:TMessage);
begin
showmessage('播放完毕!');
end;
后来采用发送命令再次发送命令查询状态才能获取当前播放的位置。
mciDeviceID := mciOpenParms.wDeviceID;
mciStatus.dwItem := MCI_STATUS_LENGTH;
mciSendCommand(mciDeviceID, MCI_STATUS,MCI_STATUS_ITEM, Longint(@mciStatus));
length_ := mciStatus.dwReturn;这样才能查询到当前播放位置精确到毫秒,我想要不停的发送命令才能获取到,当播放完成后,我也不知道,还在不停的发送,发送频率间隔比较难控制。我觉的既然有回调函数,当播放位置发送改变时,就应该调用我的回调事件中来。