怎么没有人帮助我呀
我现在用这个回调函数可是编译不通过,谁能帮我,万分感谢!!
Procedure TFMPFPlay.Open;
begin
Fillchar(FMPOpenStruct,sizeof(TFMP_OPEN_STRUCT),0);
FMPOpenStruct.lpFileName:=Pchar(PlayName);
FMPOpenStruct.dwCALLback :=DWORD(@FMPCallbackProc);//错误
FMPEGStream := FMPOpen( FMPF_BUFFERS , DWORD(@FMPOpenStruct));
end;
Function TFMPFPlay.FMPCallbackProc(bMsg: Byte;
hMPEGStream: Byte;
dwValue: DWORD): WORD stdcall;
var
Buf
Buf;
i:integer;
begin
// showmessage(inttostr(bmsg));
Result:= 0;
try
Buf:= Pointer(FMPGet(hMPEGStream, FMPI_STM_USER));
case bMsg of
//创建缓冲区
FMPM_BUF_CREATE:
begin
// showmessage('create');
GetMem(Buf,sizeof(TBuf));
//Buf := GlobalAllocPtr(GMEM_FIXED,sizeof(TBuf));
if Buf=nil then
begin
MessageBox(0,'分配内存出错,可能是内存不足!','错误',
MB_ICONEXCLAMATION);
Result:=FMPE_DOS;
Exit;
end;
Fillchar(Buf^,sizeof(TBUF),0);
Buf.hFile:= CreateFile(pChar(FPlayName),//TFMP_OPEN_STRUCT(dwValue).lpFileName,
GENERIC_READ,
FILE_SHARE_READ,
Nil,
OPEN_EXISTING,
0,
0);
if (Buf.hFile=INVALID_HANDLE_VALUE) then
begin
MessageBox(0,'打开文件出错!','错误',MB_ICONEXCLAMATION);
FreeMemory(buf);
//GlobalFreePtr( Buf );
Result:=FMPE_DOS;
Exit;
end;
for i := 0 to MAX_BUF_NUMBER-1do
GetMem(Buf.Buffer
,MAX_BUF_SIZE + 2);
//GlobalAllocPtr(GMEM_FIXED, );
Buf.wIndex := 0;
Buf.dwSize := 0;
//存储缓冲区结构到用户段
FMPSet(hMPEGStream,FMPI_STM_USER, DWORD(Buf) );
//在到缓冲区3/4时,触发填充下一个缓冲区
FMPSet(hMPEGStream, FMPI_BUF_POS, DWORD(Trunc(MAX_BUF_SIZE* 0.75)));
//FMPSet(hMPEGStream,FMPI_BUF_MODE,FMPF_BUF_LOOP);
end;
//关闭缓冲区
FMPM_BUF_CLOSE :
begin
// showmessage('close');
CloseHandle(Buf.hFile);
for i:=0 to MAX_BUF_NUMBER-1do
FreeMemory(Buf.Buffer);
//GlobalFreePtr(Buf.Buffer);
FreeMemory(Buf);
//GlobalFreePtr(Buf);
end;
//跳跃
FMPM_BUF_SEEK:
begin
// showmessage('seek');
SetFilePointer(Buf.hFile,dwValue,nil,FILE_begin
);
end;
//读书据
FMPM_BUF_POS:
begin
//showmessage('readfile');
//showmessage('pos'+inttostr(Buf.wIndex));
if ReadFile(Buf.hFile,Buf.Buffer[Buf.wIndex],MAX_BUF_SIZE,Buf.dwSize,nil) then
// SHOWMESSAGE('READ OK');
// showmessage('pos'+inttostr(Buf.dwSize));
end;
// 缓冲区空
FMPM_BUF_EMPTY : //showmessage('Empty');//BufEmpty;
begin
//showmessage('empty'+inttostr(Buf.dwSize));
FMPSet(hMPEGStream, FMPI_BUF_SIZE,Buf.dwSize );
FMPSet(hMPEGStream, FMPI_BUF_ADDRESS, DWORD(Buf.Buffer[Buf.wIndex]));
// FMPSet( ghMPEGStream, FMPI_BUF_HANDLE, (DWORD)Buf->BufferIndex[Buf->wIndex] );
Inc(Buf.wIndex);
// showmessage(inttostr(Buf.wIndex));
if (Buf.wIndex = MAX_BUF_NUMBER) then
Buf.wIndex:=0;
//Buf.wIndex := MAX_BUF_NUMBER MOD Buf.wIndex;
end;
//错误
FMPM_ERROR:
begin
// showmessage('error');
end;
//操作完成
FMPM_COMPLETED :
begin
// showmessage('COMPLETED');
if dwValue = 3 then
// 播完
begin
//if AutoPlayNext then
// PostMessage(MainForm.Handle, FMP_NEXT, 0, 0)
//else
// Showmessage('已播完,按停唱播下一首');
end;
end
end;
except
//异常
CloseHandle(Buf.hFile);
for i:=0 to MAX_BUF_NUMBER-1do
FreeMemory(Buf.Buffer);
FreeMemory(Buf);
end;
end;