1

你好亲爱的社区...

我刚刚看到 Inno Setup 的视频闪屏这个主题

视频文件(带alpha)作为启动画面?

TLama(Inno Media Player 的作者)提供的示例代码很棒,但它有一个小问题,仅此而已:代码中指向的启动视频文件具有绝对路径,如:d:\Video.avi 所以如果我想发布我的安装程序到其他计算机的绝对路径(如 d:\Video.avi)将不再工作......

因此,我要求作者 (TLama) 修改此脚本并使视频文件飞溅到相对路径,例如:{src} 或 {tmp}。

想问作者的第二个修订是:

我想通过单击窗口的客户区来实现关闭视频播放...在上面的示例代码中不可用...

所以最后我要求 TLama(Inno Media Player 的作者)对以下代码实施两个要求的修订:

    [Setup]
AppName=Media Player Project
AppVersion=1.0
DefaultDirName={pf}\Media Player Project

[Files]
Source: "MediaPlayer.dll"; Flags: dontcopy

[Code]
const
  EC_COMPLETE = $01;

type
  TDirectShowEventProc = procedure(EventCode, Param1, Param2: Integer);

function DSPlayMediaFile: Boolean;
  external 'DSPlayMediaFile@files:mediaplayer.dll stdcall';
function DSStopMediaPlay: Boolean;
  external 'DSStopMediaPlay@files:mediaplayer.dll stdcall';
function DSInitializeVideoFile(FileName: WideString; WindowHandle: HWND;
  var Width, Height: Integer; CallbackProc: TDirectShowEventProc): Boolean;
  external 'DSInitializeVideoFile@files:mediaplayer.dll stdcall';

var
  VideoForm: TSetupForm;  

procedure OnMediaPlayerEvent(EventCode, Param1, Param2: Integer); 
begin
  if EventCode = EC_COMPLETE then
    VideoForm.Close;  
end;

procedure OnVideoFormShow(Sender: TObject);
begin
  DSPlayMediaFile;
end;

procedure OnVideoFormClose(Sender: TObject; var Action: TCloseAction);
begin
  DSStopMediaPlay;
end;

procedure InitializeWizard;
var
  Width: Integer;
  Height: Integer;
begin
  VideoForm := CreateCustomForm;
  VideoForm.Caption := 'Popup Video Window';
  VideoForm.BorderStyle := bsNone;
  VideoForm.FormStyle := fsStayOnTop;
  VideoForm.Position := poScreenCenter;
  VideoForm.OnShow := @OnVideoFormShow;
  VideoForm.OnClose := @OnVideoFormClose; 

  if DSInitializeVideoFile('d:\Video.avi', VideoForm.Handle, Width, 
    Height, @OnMediaPlayerEvent)
  then
  begin
    VideoForm.ClientWidth := Width;
    VideoForm.ClientHeight := Height;     
    VideoForm.ShowModal;
  end;    
end;

procedure DeinitializeSetup;
begin
  DSStopMediaPlay;
end;
4

1 回答 1

2

'd:\video.avi'只需与ExpandConstant('{tmp}\video.avi'), 之前调用.交换即可ExtractTemporaryFile

或者,如果您想将视频与设置一起分发(例如在 DVD 上)而不是嵌入其中,请使用{src}而不是{tmp},然后跳过ExtractTemporaryFile

到第二个问题。缺少允许将IVideoWindow键盘和鼠标消息转发给窗口所有者的消息消耗。在库的更新版本中,消息已发送给所有者,因此请下载最新版本并添加如下代码以通过单击关闭视频窗口:

[Code]
procedure OnVideoFormClick(Sender: TObject); 
begin 
  // it's enough to just close the form as it owns the IVideoWindow
  VideoForm.Close;
end;

procedure InitializeWizard;
begin
  VideoForm := CreateCustomForm;
  ...
  VideoForm.OnClick := @OnVideoFormClick;
  ...
end;
于 2013-04-06T22:39:21.713 回答