杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2112|回复: 0

Inno Setup 实现循环背景音乐播放

[复制链接]
发表于 2017-1-9 16:35:23 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

您需要 登录 才可以下载或查看,没有账号?立即注册

x
以前多个帖子都是播放 MIDI 的,所以今天写个播放 mp3 的,把下面的 mp3 文件改为 WMA 的文件也可以正常播放。

注意, midi ,wav 的文件不能适用于以下脚本,同时这两种音乐文件也不能循环播放,当然,如果是在实际的程序设计中,可以自己循环检测当前的播放状态,从而达到重复播放,但是却不可以在一个调用中实现重复播放。所以在安装程序中很难实现。

以下为脚本
  1. ; -- Components.iss --
  2. ; 安装程序背景音乐循环播放脚本演示

  3. [Setup]
  4. AppName=我的程序
  5. AppVerName=我的程序 版本 1.5
  6. DefaultDirName={pf}\我的程序
  7. DefaultGroupName=我的程序
  8. UninstallDisplayIcon={app}\MyProg.exe

  9. [Types]
  10. Name: "full"; Description: "完整安装"
  11. Name: "compact"; Description: "简洁安装"
  12. Name: "custom"; Description: "自定义安装"; Flags: iscustom

  13. [Components]
  14. Name: "program"; Description: "程序文件"; Types: full compact custom; Flags: fixed
  15. Name: "help"; Description: "帮助文件"; Types: full
  16. Name: "readme"; Description: "自述文件"; Types: full
  17. Name: "readme\en"; Description: "简体中文"; Flags: exclusive
  18. Name: "readme\de"; Description: "德文G"; Flags: exclusive

  19. [Files]
  20. Source: "MyProg.exe"; DestDir: "{app}"; Components: program
  21. Source: "MyProg.hlp"; DestDir: "{app}"; Components: help
  22. Source: "Readme.txt"; DestDir: "{app}"; Components: readme\en; Flags: isreadme
  23. Source: "Readme-German.txt"; DestName: "Liesmich.txt"; DestDir: "{app}"; Components: readme\de; Flags: isreadme
  24. Source: "sss.mp3"; DestDir: "{tmp}"; Flags: dontcopy

  25. [Icons]
  26. Name: "{group}\我的程序"; Filename: "{app}\MyProg.exe"

  27. [code]
  28. function mciSendString(lpstrCommand, lpstrReturnString: PChar; uReturnLength: UINT; hWndCallback: HWND): Integer;
  29. external 'mciSendStringA@winmm.dll stdcall';

  30. procedure InitializeWizard();
  31. var
  32.   s: string;
  33. begin
  34.     ExtractTemporaryFile(ExtractFileName(ExpandConstant('{tmp}\sss.mp3')));
  35.     mciSendString(ExpandConstant('OPEN {tmp}\sss.mp3 TYPE MPEGVIDEO ALIAS BGMUSIC'),s,255,0);
  36.     mciSendString(ExpandConstant('PLAY BGMUSIC REPEAT'),s,255,0);
  37. end;
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-5-2 10:39 , Processed in 0.121758 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表