发新话题
打印

请问DELPHI中,用MciSendString函数播放视频文件,如何得到视频窗体指定在OLE控件上? ...

请问DELPHI中,用MciSendString函数播放视频文件,如何得到视频窗体指定在OLE控件上? ...

请问DELPHI中,用MciSendString函数播放视频文件,如何得到视频窗体指定在OLE控件上?这代码错在哪?
      cmd := 'window ' + myMusic + ' handle ' + pchar(OLE);
    fplay := mcisendstring(pchar(cmd), nil, 0, 0);

      cmd := 'put ' + Mymusic + ' destination at ' + Trim(IntToStr(0)) + ' ' + Trim(IntToStr(0)) + ' ' + Trim(IntToStr(OLE.Width)) + ' ' + Trim(IntToStr(OLE.Height));
    fplay := mcisendstring(pchar(cmd), nil, 0, 0);

TOP

播放的时候指定窗口或OLE控件的hWnd
使用如用下面的MCI命令
open  文件名  type MPEGVideo alias 播放名字 parent  指定的hWnd  style child

TOP

你用的Windows命令是没有任何作用的。
你先用我上面的命令打开,打能使用PUT命令指定窗口的大小。

TOP

procedure TForm1.Button1Click(Sender: TObject);
var
  typeDevice : String;
  Hwnds : String;
Const
  WS_CHILD = '1073741824';
begin
  typeDevice := 'MPEGVideo';
  if opendlg.Execute then
  begin
    myMusic := 'myMusic';
    lbox.Items := opendlg.Files;
    lbox.ItemIndex := 0;
    pfile := lbox.Items[lbox.itemindex];
    Str(OleWnd.Handle,Hwnds);
      cmd := 'close ' + myMusic;
    fplay := mcisendstring(pchar(cmd), '', 0, 0);

      cmd := 'open ' + pfile + ' type ' + typeDevice + ' Alias ' + myMusic + ' parent ' + hwnds + ' Style ' + WS_CHILD + ' shareable';
    fplay := mciSendString(pchar(cmd), '', 0, 0);

      cmd := 'put ' + Mymusic + ' destination at ' + Trim(IntToStr(0)) + ' ' + Trim(IntToStr(0)) + ' ' + Trim(IntToStr(Olewnd.ClientWidth)) + ' ' + Trim(IntToStr(OleWnd.ClientHeight));
    fplay := mcisendstring(pchar(cmd), nil, 0, 0);

      cmd := 'play ' + myMusic;
    fplay := mcisendstring(pchar(cmd), '', 0, 0);
    if fplay <> 0 then
      showmessage('error');
  end;
end;

呵,行了。。。

TOP

发新话题