Play Sound: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
No edit summary |
(No difference)
|
Revision as of 18:11, 28 November 2005
| Author: Takhir (talk, contrib) |
Description
Requires: System plug-in.
Plays sound using MCIWnd class (MS VFW DLL)
The Script
;-------------------------------- ; Definitions & Attributes !define APP_NAME "mci.sound" !define SND_NAME "tango.mp3" Name "${APP_NAME}" OutFile "${APP_NAME}.exe" ;-------------------------------- ; Pages, Interface Settings, Languages !include "MUI.nsh" !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !insertmacro MUI_LANGUAGE "English" ;-------------------------------- ; User Vars - optional, for WM_CLOSE (if used) Var hmci ;-------------------------------- ; Required for big packages only ReserveFile "${NSISDIR}\Plugins\system.dll" ReserveFile "${SND_NAME}" ;-------------------------------- ; Installer Functions Function .onInit InitPluginsDir SetOutPath $PLUGINSDIR File "${SND_NAME}" ; this is very beginning of the code, so we may skip Push and Pop for $0 - it is not in use yet System::Call 'msvfw32.dll::MCIWndCreate(i 0, i 0,i 0x0070, t "$PLUGINSDIR\${SND_NAME}") i .r0' ; if you want mci window to be hidden ShowWindow $0 SW_HIDE ; you can use "STR:play" or "STR:play repeat", but I saw "repeat" problems with midi files SendMessage $0 0x0465 0 "STR:play" ; saves MCI window handle for WM_CLOSE in SecDummy StrCpy $hmci $0 FunctionEnd ;-------------------------------- ; Installer Sections Section "Dummy Section" SecDummy ; add your code here Sleep 1000 ; just to show & animate instfiles page, i.e. for DEMO only :) Sleep 1000 Sleep 1000 ; stops sound at the end of last section, i.e. when 'finish' page is to be displayed ; otherwise it will auto-stop on installer exit. Finally you can skip Var hmci, it's ; StrCpy and SendMessage below if you don't want silence on the 'finish' page. SendMessage $hmci ${WM_CLOSE} 0 0 SectionEnd