我把代码贴一下,哪位帮我看看吧? 这个F_Play是开始按钮 procedure TFrmplayback.F_Play; var fileselpos :integer; csFileName :pchar; csIP,csTemp, sTemp1 :String; nPos :integer; boolreturn:boolean; begin if(m_locFileList.Selected = nil) then begin showMessage('请选择要播放的文件!'); exit; end; //PlayM4_SetFileRefCallBack(USED_PORT,FileRefDone,(DWORD)this); csFileName := pchar(m_locFileList.Selected.caption); if(Length(csFileName)=0) then exit; csTemp:=csFileName; while(Pos('\',csTemp)>0) do begin csIP:=Rightstr(csTemp,Length(csTemp)-nPos); //showmessage(csIP); csTemp:=csIP; nPos:=pos('\',csTemp); end; nPos:=pos('_',csTemp); csIP:=Leftstr(csTemp,nPos-1); m_csIP:=csIP; if(PlayM4_OpenFile(USED_PORT,csFileName)=false) then //调用PlayM4_OpenFile begin showmessage('open file failed!'); exit; end; sTemp1 := m_locFileList.Selected.Caption; iSelChannel := midstr(sTemp1,pos('_',sTemp1)+1,2); m_iTotalSeconds:=0; m_iTotalSeconds:=PlayM4_GetFileTime(USED_PORT); //调用PlayM4_GetFileTime if(m_iTotalSeconds<=0) then begin boolreturn:=PlayM4_CloseFile(USED_PORT); showmessage('文件大小为0!'); exit; end; boolreturn:=PlayM4_SetDisplayCallBack(USED_PORT,DisplayCBFun);//调用PlayM4_SetDisplayCallBack if((PlayM4_Play(USED_PORT,Frmplayback.Panel1.Handle))=FALSE) then //调用PlayM4_Play begin err:=PlayM4_GetLastError(USED_PORT); if err=NET_DVR_PASSWORD_ERROR then showmessage('用户名密码错误') else showmessage(inttostr(err)); boolreturn:=PlayM4_CloseFile(USED_PORT); end; F_Sound(TRUE); //调用F_Sound end; procedure TFrmplayback.F_Sound(bSound: boolean); var boolreturn:boolean; begin if(bSound) then begin m_bSound:=PlayM4_PlaySound(USED_PORT); boolreturn:=PlayM4_SetVolume(USED_PORT,32767); end else begin boolreturn:=PlayM4_StopSound(); m_bSound:=FALSE; end; end; 以下为停止按钮 f_pause; boolreturn:=PlayM4_Stop(USED_PORT); boolreturn:=PlayM4_CloseFile(USED_PORT); F_Sound(false);
procedure TFrmplayback.F_Pause; begin if(PlayM4_Pause(USED_PORT, not m_bPause)) then begin m_bPause:=not m_bPause; end else begin //TRACE("PAUSE ERROR!"); showmessage('PAUSE ERROR!'); end; end;
TPanel是标准的win32控件。
这个F_Play是开始按钮
procedure TFrmplayback.F_Play;
var
fileselpos :integer;
csFileName :pchar;
csIP,csTemp, sTemp1 :String;
nPos :integer;
boolreturn:boolean;
begin if(m_locFileList.Selected = nil) then
begin
showMessage('请选择要播放的文件!');
exit;
end;
//PlayM4_SetFileRefCallBack(USED_PORT,FileRefDone,(DWORD)this);
csFileName := pchar(m_locFileList.Selected.caption);
if(Length(csFileName)=0) then
exit;
csTemp:=csFileName; while(Pos('\',csTemp)>0) do
begin
csIP:=Rightstr(csTemp,Length(csTemp)-nPos);
//showmessage(csIP);
csTemp:=csIP;
nPos:=pos('\',csTemp);
end;
nPos:=pos('_',csTemp);
csIP:=Leftstr(csTemp,nPos-1);
m_csIP:=csIP;
if(PlayM4_OpenFile(USED_PORT,csFileName)=false) then //调用PlayM4_OpenFile
begin
showmessage('open file failed!');
exit;
end;
sTemp1 := m_locFileList.Selected.Caption;
iSelChannel := midstr(sTemp1,pos('_',sTemp1)+1,2);
m_iTotalSeconds:=0;
m_iTotalSeconds:=PlayM4_GetFileTime(USED_PORT); //调用PlayM4_GetFileTime if(m_iTotalSeconds<=0) then
begin
boolreturn:=PlayM4_CloseFile(USED_PORT);
showmessage('文件大小为0!');
exit;
end;
boolreturn:=PlayM4_SetDisplayCallBack(USED_PORT,DisplayCBFun);//调用PlayM4_SetDisplayCallBack
if((PlayM4_Play(USED_PORT,Frmplayback.Panel1.Handle))=FALSE) then //调用PlayM4_Play
begin
err:=PlayM4_GetLastError(USED_PORT);
if err=NET_DVR_PASSWORD_ERROR then
showmessage('用户名密码错误')
else
showmessage(inttostr(err));
boolreturn:=PlayM4_CloseFile(USED_PORT);
end;
F_Sound(TRUE); //调用F_Sound
end;
procedure TFrmplayback.F_Sound(bSound: boolean);
var boolreturn:boolean;
begin if(bSound) then
begin
m_bSound:=PlayM4_PlaySound(USED_PORT);
boolreturn:=PlayM4_SetVolume(USED_PORT,32767);
end
else
begin
boolreturn:=PlayM4_StopSound();
m_bSound:=FALSE;
end;
end;
以下为停止按钮
f_pause;
boolreturn:=PlayM4_Stop(USED_PORT);
boolreturn:=PlayM4_CloseFile(USED_PORT);
F_Sound(false);
procedure TFrmplayback.F_Pause;
begin
if(PlayM4_Pause(USED_PORT, not m_bPause)) then
begin
m_bPause:=not m_bPause;
end
else
begin
//TRACE("PAUSE ERROR!");
showmessage('PAUSE ERROR!');
end;
end;