本文介绍了如何使安装程序具有背景窗口图像幻灯片显示和无限的音乐循环播放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想安装到我的安装程序中

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

如何在InnoSetup中执行此操作?

How to do this in InnoSetup ?

推荐答案

如果您要安装的背景音乐幻灯片具有无限的音乐曲目播放功能,则可以执行以下操作:以下:

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:

编写类似于以下内容的脚本,或者 download the complete project ,其中包含下一个脚本代码中使用的所有必需文件.因此,您唯一需要做的就是在最新版本的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.

请注意,Inno Media Player是Unicode库,因此您只能将其与Inno Setup的Unicode版本一起使用,而不能与ANSI版本一起使用!不支持ANSI版本的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 '[email protected] stdcall';
function KillTimer(hWnd: HWND; uIDEvent: UINT): BOOL; 
  external '[email protected] 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:

这篇关于如何使安装程序具有背景窗口图像幻灯片显示和无限的音乐循环播放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 01:53