调整 MediaPlayer 的大小,无需播放按钮控件

发布于 2024-09-27 16:04:31 字数 70 浏览 3 评论 0原文

我想编写一个不带播放控件的可调整大小的 WindowsMediaplayer (ActiveX)。它应该适合 TPanels。

I wanted to code a resizeable WindowsMediaplayer (ActiveX) without the play controls. it should fit to TPanels.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愁杀 2024-10-04 16:04:31

不久前我必须解决这个问题,经过大量谷歌搜索后,我发现这可以工作

将 WindowsMedaiPlayer 对象放在面板上,并将其与 alclient 对齐,
可以使用 uiMode := 'none' 隐藏播放器控制区域,在 ide 或代码中设置,

然后使用改编

uses Ole2;

procedure TForm1.Panel1Resize(Sender: TObject);
 const
    IID_IOleInPlaceObject: SYSTEM.TGUID = '{00000113-0000-0000-C000-000000000046}';
 var
  IOIPObj: IOleInPlaceObject;
 begin
  SYSTEM.IDispatch(WindowsMediaPlayer1.OleObject).QueryInterface(IID_IOleInPlaceObject, IOIPObj);
  IOIPObj.SetObjectRects(Panel1.ClientRect, Panel1.ClientRect);
 end;


procedure TForm1.Play;
 begin
  WindowsMediaPlayer1.uiMode := 'none';  //show no interface, this can be set from the ide
  WindowsMediaPlayer1.URL := 'movie.mpg';
  WindowsMediaPlayer1.stretchToFit := True;
  WindowsMediaPlayer1.Controls.play;
 end;

http://our.obor.us/node/1999

Ole2 用于 IOleInPlaceObject,我必须添加 $(Delphi)\source\rtl\ Win到delphi的库路径即可找到它。

(delphi 7,wmp 11)

额外:一些更容易使用

uses Ole2; 

procedure SmoothResizeMediaPlayer(aMediaPlayer: TWindowsMediaPlayer; PosRect,ClipRect:Trect);
const
  IID_IOleInPlaceObject: SYSTEM.TGUID = '{00000113-0000-0000-C000-000000000046}';
var
  IOIPObj: IOleInPlaceObject;
begin
  SYSTEM.IDispatch(aMediaPlayer.OleObject).QueryInterface(IID_IOleInPlaceObject, IOIPObj);
  IOIPObj.SetObjectRects(PosRect, ClipRect);
end;

和调用的东西

  SmoothResizeMediaPlayer(WindowsMediaPlayer1, panel1.ClientRect, panel1.ClientRect);

I had to work this out a while ago, and after lots of googling i found this to work

Put a WindowsMedaiPlayer object on the Panel, and setting its align to alclient,
the player control area can be hidden with uiMode := 'none', set in the ide or code

then assigning the Panels resize event with

uses Ole2;

procedure TForm1.Panel1Resize(Sender: TObject);
 const
    IID_IOleInPlaceObject: SYSTEM.TGUID = '{00000113-0000-0000-C000-000000000046}';
 var
  IOIPObj: IOleInPlaceObject;
 begin
  SYSTEM.IDispatch(WindowsMediaPlayer1.OleObject).QueryInterface(IID_IOleInPlaceObject, IOIPObj);
  IOIPObj.SetObjectRects(Panel1.ClientRect, Panel1.ClientRect);
 end;


procedure TForm1.Play;
 begin
  WindowsMediaPlayer1.uiMode := 'none';  //show no interface, this can be set from the ide
  WindowsMediaPlayer1.URL := 'movie.mpg';
  WindowsMediaPlayer1.stretchToFit := True;
  WindowsMediaPlayer1.Controls.play;
 end;

Adapted from http://our.obor.us/node/1999

Ole2 is for IOleInPlaceObject, i had to add $(Delphi)\source\rtl\Win to the library path for delphi to find it.

(delphi 7, wmp 11)

Extra: Something a bit easier to use

uses Ole2; 

procedure SmoothResizeMediaPlayer(aMediaPlayer: TWindowsMediaPlayer; PosRect,ClipRect:Trect);
const
  IID_IOleInPlaceObject: SYSTEM.TGUID = '{00000113-0000-0000-C000-000000000046}';
var
  IOIPObj: IOleInPlaceObject;
begin
  SYSTEM.IDispatch(aMediaPlayer.OleObject).QueryInterface(IID_IOleInPlaceObject, IOIPObj);
  IOIPObj.SetObjectRects(PosRect, ClipRect);
end;

and Called with

  SmoothResizeMediaPlayer(WindowsMediaPlayer1, panel1.ClientRect, panel1.ClientRect);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文