Video file (with alpha) as splash-screen?

2019-02-27 09:52发布

问题:

I'm searching for quite a while now for an extension for Inno Setup to use a video file, for example an AVI or maybe a .png sequence as a splash-screen for my installation (the usage of an alpha channel would be a HUGE plus but is not a must have). There are several .dll's to use static pictures with a fade-in and fade-out but I couldn't find anything to use as video file for that purpose.

As far as I know, I can use any kind of .dll with Inno Setup. For example I can use the popular bass.dll for audio playback even though it has no "real" Inno support but Inno can call the functions of that .dll.

So is there any program out there that would allow me to do this? Any tip in that direction would be very helpful.

Edit: This may be possible with Qt, I know you can make exactly those frame based splash-screens for your applications but I'm not sure if it's possible to use Qt with Inno Setup?

回答1:

I have founded the Inno Media Player project which is able to embed the video and audio playback into the InnoSetup wizard. It is based on DirectShow technology and requires at least DirectX 9 to use.

Except built-in formats it supports all DirectShow codecs, but you should consider that your target users doesn't need to have codecs for some exotic media formats and install them codec just because of the show at the installation startup would be an overkill and unfair to user.

About the transparency you wanted to have, if you find the codec that supports that, we can try to make the popup window transparent and let the DirectShow renderer draw on a layered window, but without the codec and a sample video I can't do nothing.

  • the libraries with a sample script you may find in the source trunk or download it from here
  • I wrote a simple function reference where you can find the function parameter descriptions

So to show a popup window with the video playback before the wizard form is displayed you can use the following:

Please note, that Inno Media Player is a Unicode library, and so you can use it only with Unicode versions of InnoSetup, not with ANSI ones! There is no support for ANSI versions of InnoSetup...!

[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;

Hope that it helps!