I just saw this topic for video splash screen for Inno Setup
Video file (with alpha) as splash-screen?
The sample code presented by @TLama (Author of Inno Media Player) is great but it has a little problem and that's this:
Splash video file that is pointed in code has absolute path like: d:\Video.avi
So if I want to publish my setup program to other computers absolute path like d:\Video.avi
will not work anymore...
Therefore I am asking the author (@TLama) to revise this script and make the video file splash with relative path like: {src}
or {tmp}
.
The second revision that want to ask author is that:
I want to implement closing of the video playback by clicking the client area of a window...that is not available in above sample code...
My script:
[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;
Just swap 'd:\video.avi'
with ExpandConstant('{tmp}\video.avi')
, with a prior call to ExtractTemporaryFile
.
Or if you want to distribute the video alongside the setup (eg. on DVD) rather than embedded into it, then use {src}
instead of {tmp}
, and skip ExtractTemporaryFile
.
To the second question. There was missing the message drain which would allow the IVideoWindow
forward keyboard and mouse messages to the window owner. In the updated version of the library the messages are dispatched to the owner, so download the latest version and add the code like this to close the video window by clicking on it:
[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;