1

I would like to have in my installer:

  • an infinite music loop playback during installation

  • a window on the background (like the old installations that used to fill the screen with an image and only show the installation window), with a slideshow on that background window

How to do this in InnoSetup ?

TLama
  • 75,147
  • 17
  • 214
  • 392
kyle1046
  • 383
  • 4
  • 18
  • -1 You have to work in your grammar, this is very difficult to read. Being in Florida, there are high chances you're a native English speaker, so I will not edit your post to correct the lack of punctuation and other stuff. – jachguate Jan 30 '13 at 23:21
  • You can use e.g. the [`Inno Media Player`](http://code.google.com/p/inno-media-player/wiki/Introduction). Here's [an example of how to play sound](http://stackoverflow.com/q/12359859/960757). `` :-) Here is [how to make a slideshow](http://stackoverflow.com/a/10130637/960757) and finally to show that old style window on the background, use the [`WindowVisible`](http://jrsoftware.org/ishelp/topic_setup_windowvisible.htm) directive. – TLama Jan 30 '13 at 23:29
  • @TLama i had read that one first but that was targeted towards and app not an installation and i cant even figure out whats really going on it it to understand it so i figured it was having all the other stuff i didn't need but the thing still doesnt tell how to make it loop the music – kyle1046 Jan 30 '13 at 23:31
  • See [that example](http://stackoverflow.com/q/12359859/960757) and read the comment in the `OnMediaPlayerEvent` callback method. It's nothing more than using the same audio playback initialization code inside of that event method... ;-) – TLama Jan 30 '13 at 23:51
  • well i can say this for sure i keep getting errors with that code and even the example code that's included like these unknown type 'WideString' remove all of them and then this unknown type 'HRESULT' remove it then this unknown identifier 'DSInitializeAudeoFile' and it there's even more errors i keep finding – kyle1046 Jan 31 '13 at 00:01
  • That's because you're using old school ANSI version of InnoSetup and because I haven't disclaimed on the project site, that you must use it only with Unicode versions of InnoSetup. You have two options, either you may download and use Unicode InnoSetup or look for a different media library :-) If you'll decide for the first option, [`here you have a complete example`](http://code.google.com/p/projects-stackoverflow-tlama/downloads/detail?name=14615631.ZIP) of what you want to do (as I get that). – TLama Jan 31 '13 at 00:36

2 Answers2

6

If you want to have an installer with a background image slideshow with an infinite music track playback, you can do e.g. the following:

  • get the recent version of the InnoCallback library for slideshow timer implementation
  • for music playback get e.g. most recent copy of the Inno Media Player for Unicode Inno Setup

Write a script similar to following, or download the complete project, which includes all necessary files used in the next script code. So the only thing you'd need to do, is to build it in the recent version of Unicode Inno Setup.

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

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
OutputDir=userdocs:Inno Setup Examples Output
BackColor=clLime
BackColor2=clYellow
WindowVisible=yes

[Files]
Source: "Image1.bmp"; Flags: dontcopy
Source: "Image2.bmp"; Flags: dontcopy
Source: "AudioFile.mp3"; Flags: dontcopy
Source: "MediaPlayer.dll"; Flags: dontcopy
Source: "InnoCallback.dll"; Flags: dontcopy

[Code]
var
  TimerID: Integer;
  SlideID: Integer;
  BackImage: TBitmapImage;
const
  EC_COMPLETE = $01;
type
  TTimerProc = procedure(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR; 
    SysTime: DWORD);
  TDirectShowEventProc = procedure(EventCode, Param1, Param2: Integer);

function WrapTimerProc(Callback: TTimerProc; ParamCount: Integer): LongWord;
  external 'wrapcallback@files:InnoCallback.dll stdcall';    
function SetTimer(hWnd: HWND; nIDEvent, uElapse: UINT;
  lpTimerFunc: UINT): UINT; external 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd: HWND; uIDEvent: UINT): BOOL; 
  external 'KillTimer@user32.dll stdcall'; 

function DSGetLastError(var ErrorText: WideString): HRESULT;
  external 'DSGetLastError@files:mediaplayer.dll stdcall';
function DSPlayMediaFile: Boolean;
  external 'DSPlayMediaFile@files:mediaplayer.dll stdcall';
function DSStopMediaPlay: Boolean;
  external 'DSStopMediaPlay@files:mediaplayer.dll stdcall';
function DSSetVolume(Value: LongInt): Boolean;
  external 'DSSetVolume@files:mediaplayer.dll stdcall';
function DSInitializeAudioFile(FileName: WideString; 
  CallbackProc: TDirectShowEventProc): Boolean; 
  external 'DSInitializeAudioFile@files:mediaplayer.dll stdcall';

procedure OnMediaPlayerEvent(EventCode, Param1, Param2: Integer); 
begin
  if EventCode = EC_COMPLETE then
  begin
    if DSInitializeAudioFile(ExpandConstant('{tmp}\AudioFile.mp3'), 
      @OnMediaPlayerEvent) then
    begin
      DSSetVolume(-2500);
      DSPlayMediaFile;
    end;
  end;
end;

procedure OnSlideTimer(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR; 
  SysTime: DWORD);
begin
  case SlideID of 
    0: SlideID := 1;
    1: SlideID := 0;
  end;
  BackImage.Bitmap.LoadFromFile(
    ExpandConstant('{tmp}\Image' + IntToStr(SlideID + 1) + '.bmp'));
end;

procedure StartSlideTimer;
var
  TimerCallback: LongWord;
begin
  TimerCallback := WrapTimerProc(@OnSlideTimer, 4);
  { third parameter here is the timer's timeout value in milliseconds }
  TimerID := SetTimer(0, 0, 5000, TimerCallback);
end;

procedure KillSlideTimer;
begin
  if TimerID <> 0 then 
  begin
    if KillTimer(0, TimerID) then
      TimerID := 0;
  end;
end;

procedure InitializeWizard;
var
  ErrorCode: HRESULT;
  ErrorText: WideString;   
begin
  TimerID := 0;
  SlideID := 0;
  ExtractTemporaryFile('Image1.bmp');
  ExtractTemporaryFile('Image2.bmp');
  BackImage := TBitmapImage.Create(MainForm);
  BackImage.Parent := MainForm;
  BackImage.Top := 70;
  BackImage.Left := 10;  
  BackImage.AutoSize := True;
  BackImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\Image1.bmp'));
  StartSlideTimer;

  ExtractTemporaryFile('AudioFile.mp3');
  if DSInitializeAudioFile(ExpandConstant('{tmp}\AudioFile.mp3'), 
    @OnMediaPlayerEvent) then
  begin
    DSSetVolume(-2500);
    DSPlayMediaFile;
  end
  else
  begin
    ErrorCode := DSGetLastError(ErrorText);
    MsgBox('TDirectShowPlayer error: ' + IntToStr(ErrorCode) + '; ' + 
      ErrorText, mbError, MB_OK);
  end;
end;

procedure DeinitializeSetup;
begin
  KillSlideTimer;
  DSStopMediaPlay;
end;

Further resources:

Community
  • 1
  • 1
TLama
  • 75,147
  • 17
  • 214
  • 392
  • One can say, it takes a long time before the sound playback is initialized, but please take into account it's not the fault of the library itself, but of the first DirectShow filter graph initialization. – TLama Jan 31 '13 at 01:07
0

Creating backgrounds feature:

Did you try Graphical Installer (http://www.graphical-installer.com) ?

It is a professional Inno Setup extension specially for this (creating cool looking installers with background) so creating such installer is matter of few minutes (no coding is required).

Slappy
  • 5,250
  • 1
  • 23
  • 29