当前位置: 首页 > 教程资源 > Inno Setup 教程 > 正文
Inoo Setup 增加背景音乐播放和暂停继续按钮解决方案

Inoo Setup 增加背景音乐播放和暂停继续按钮解决方案

作者:大眼仔~旭 日期:4年前 (2020-11-16) 评论:1 条

摘要:Inno Setup 是开源免费的安装包构建软件,支持脚本编程可扩展性非常强悍。除了常见的向导式安装界面外,我们可以通过使用第三方开发的插件高度自定义化安装向导界面。现在很多大厂的安装包有些是使用 Nsis 制作的安装包,有些是采用 Inno Setup 制作的安装包。今天大眼仔旭和大家一起分享的是为您的 Inno S…

Inno Setup 是开源免费的安装包构建软件,支持脚本编程可扩展性非常强悍。除了常见的向导式安装界面外,我们可以通过使用第三方开发的插件高度自定义化安装向导界面。现在很多大厂的安装包有些是使用 Nsis 制作的安装包,有些是采用 Inno Setup 制作的安装包。今天大眼仔旭和大家一起分享的是为您的 Inno Setup 安装包增加背景音乐及播放控制功能,该版本主要使用了 Bass.dll 的音乐播放模块进行调用即可实现。

Inoo Setup 增加背景音乐播放和暂停继续按钮解决方案

Inoo Setup 背景音乐播放示例

Inoo Setup 增加背景音乐播放和暂停继续按钮解决方案:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
[Setup]
AppName=Bass Audio Project
AppVersion=1.0
DefaultDirName={pf}\Bass Audio Project
AppPublisher=大眼仔~旭(Anan)
AppPublisherURL=http://www.dayanzai.me
AppSupportURL=http://www.dayanzai.me

[Messages]
BeveledLabel=大眼仔~旭感情无限公司(Anan)国际

[Files]
Source: Bass.dll; Flags: dontcopy
Source: AudioFile.mp3; Flags: dontcopy

[Code]
const
  BASS_SAMPLE_LOOP = 4;
  BASS_ACTIVE_STOPPED = 0;
  BASS_ACTIVE_PLAYING = 1;
  BASS_ACTIVE_STALLED = 2;
  BASS_ACTIVE_PAUSED  = 3;
  BASS_UNICODE = $80000000;
  BASS_CONFIG_GVOL_STREAM = 5;
const
  #ifndef UNICODE
    EncodingFlag = 0;
  #else
    EncodingFlag = BASS_UNICODE;
  #endif
type
  HSTREAM = DWORD;

function BASS_Init(device: LongInt; freq, flags: DWORD;
  win: HWND; clsid: Cardinal): Boolean;
  external 'BASS_Init@files:bass.dll stdcall';
function BASS_StreamCreateFile(mem: Boolean; f: string; offset1: DWORD;
  offset2: DWORD; length1: DWORD; length2: DWORD; flags: DWORD): HSTREAM;
  external 'BASS_StreamCreateFile@files:bass.dll stdcall';
function BASS_ChannelPlay(handle: DWORD; restart: Boolean): Boolean;
  external 'BASS_ChannelPlay@files:bass.dll stdcall';
function BASS_ChannelPause(handle: DWORD): Boolean;
  external 'BASS_ChannelPause@files:bass.dll stdcall';
function BASS_SetConfig(option: DWORD; value: DWORD ): Boolean;
  external 'BASS_SetConfig@files:bass.dll stdcall';
function BASS_ChannelIsActive(handle: DWORD): DWORD;
  external 'BASS_ChannelIsActive@files:bass.dll stdcall';

var
  SoundStream: HSTREAM;
  PauseResumePlayButton: TNewButton;
  StopButton: TNewButton;

procedure ResumeButtonClick(Sender: TObject); forward;

procedure PauseButtonClick(Sender: TObject);
begin
  if BASS_ChannelPause(SoundStream) then
  begin
    PauseResumePlayButton.Caption := '继续';
    PauseResumePlayButton.OnClick := @ResumeButtonClick;
  end;
end;

procedure ResumeButtonClick(Sender: TObject);
begin
  if BASS_ChannelPlay(SoundStream, False) then
  begin
    PauseResumePlayButton.Caption := '暂停';
    PauseResumePlayButton.OnClick := @PauseButtonClick;
  end;
end;

procedure PlayButtonClick(Sender: TObject);
begin
  if BASS_ChannelPlay(SoundStream, True) then
  begin
    PauseResumePlayButton.Caption := '暂停';
    PauseResumePlayButton.OnClick := @PauseButtonClick;
  end;
end;

procedure StopButtonClick(Sender: TObject);
begin
  if (BASS_ChannelIsActive(SoundStream) = BASS_ACTIVE_PAUSED) or
     BASS_ChannelPause(SoundStream) then
  begin
    PauseResumePlayButton.Caption := '播放';
    PauseResumePlayButton.OnClick := @PlayButtonClick;
  end;
end;

procedure InitializeWizard();
begin
  if BASS_Init(-1, 44100, 0, 0, 0) then
  begin
    ExtractTemporaryFile('AudioFile.mp3');
    SoundStream :=
      BASS_StreamCreateFile(
        False, ExpandConstant('{tmp}\AudioFile.mp3'), 0, 0, 0, 0,
        EncodingFlag or BASS_SAMPLE_LOOP);

    if SoundStream <> 0 then
    begin
      BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 2500);

      if BASS_ChannelPlay(SoundStream, False) then
      begin
        StopButton := TNewButton.Create(WizardForm);
        StopButton.Parent := WizardForm;
        StopButton.Left :=
          WizardForm.ClientWidth -
          WizardForm.CancelButton.Left -  WizardForm.CancelButton.Width;
        StopButton.Top := WizardForm.CancelButton.Top;
        StopButton.Width :=  WizardForm.CancelButton.Width;
        StopButton.Height := WizardForm.CancelButton.Height;
        StopButton.Caption := '停止';
        StopButton.OnClick := @StopButtonClick;

        PauseResumePlayButton := TNewButton.Create(WizardForm);
        PauseResumePlayButton.Parent := WizardForm;
        PauseResumePlayButton.Left :=
          WizardForm.ClientWidth -
          WizardForm.NextButton.Left -  WizardForm.NextButton.Width;
        PauseResumePlayButton.Top := WizardForm.CancelButton.Top;
        PauseResumePlayButton.Width :=  WizardForm.CancelButton.Width;
        PauseResumePlayButton.Height := WizardForm.CancelButton.Height;
        PauseResumePlayButton.Caption := '暂停';
        PauseResumePlayButton.OnClick := @PauseButtonClick;
      end;
    end;
  end;
end;

结尾大眼仔还给大家提供了 Inno Setup 源代码下载,音乐文件或者音频文件名称大家可以根据自己的需要进行修改即可。

资源:440.rar
解压密码:www.dayanzai.me
转载请保留出处,谢谢合作~
点击下载
点击下载
点击下载(提取码:aseu)
点击下载(提取码:6734)

声明:大眼仔旭 | 本文采用署名-非商业性使用-相同方式共享 4.0 国际许可协议[CC BY-NC-SA]进行授权
文章名称:《Inoo Setup 增加背景音乐播放和暂停继续按钮解决方案
文章固定链接:http://www.dayanzai.me/inoo-setup-player.html
本站资源仅供个人学习交流,请于下载后 24 小时内删除,不允许用于商业用途,否则法律问题自行承担。
转载声明
全部评论: (1条)
  1. 流光2019-01-04 15:13 回复
    win10下无法转换任何格式,进入格式选择为空白

发表评论

返回顶部