Answer
Windows Installer cannot play an audio file during the install process. However, in Advanced Installer this can be done by using the "PlayAudioFile" predefined custom action. This custom action uses the AI_AUDIOFILE_PATH property which must be set to the full path of the audio file. Additionally, you can use the AI_AUDIOFILE_UI property to run the custom action before or after the InstallExecuteSequence.
Play an audio file during installation
In order to play an audio file during the install process you can follow these steps:
- in the Files and Folders page, add the audio file as a temporary file
- double-click the temporary file to show the Edit Temporary File dialog
- in this dialog, set the "Property" field to AI_AUDIOFILE_PATH
- go to the Custom Actions page
- under InstallUISequence -> WelcomeDlg, add a Play Audio File custom action
- set the "Expression" field in the Custom Action Properties page to (Not Installed)
The playback will stop automatically once the installation is complete, if an error occurs or if the user cancels the installation.
It is recommended adding the temporary file in the Windows
Volume -> Temporary folder from the Files and Folders page.
If the temporary file is added in a per-machine folder, the
installation may not have enough privileges to extract it. In this
case, the file will not be played.
Play an audio file when a button is pressed
This can be done only in an Enterprise or Architect
project
You can also play an audio file when the user presses a button on a custom dialog:
- in the Files and Folders page, add the audio file as a temporary file
- double-click the temporary file to show the Edit Temporary File dialog
- in this dialog set the "Property" field to AI_AUDIOFILE_PATH
- go to the Custom Actions page
- under UI Custom Actions add a Play Audio File custom action (do not modify its settings)
- under "InstallUISequence" show the "Begin" standard action (you can use the "Show Standard Action" button on the toolbar)
- under it, create a new "Property Set with Formatted" custom action
- set the "Property Name" field to AI_AUDIOFILE_UI
- set the "Formatted Text" field to Play (this will let the custom action know that the file will be played in the UI)
- under "InstallUISequence" show the "ExecuteAction" standard action
- under it, create a new "Property Set with Formatted" custom action (it will make the installer stop playing the file right before "ExitDialog" is showed)
- set the "Property Name" field to AI_AUDIOFILE_UI
- set the "Formatted Text" field to Stop (the "Expression" field can be left empty)
- in the Dialogs page select the button which will start playing the file
- under the "Published Events" tab create a new DoAction control event which looks like this:
DoAction PlayAudioFile AI_INSTALL
- this control event will start playing the file, so you need to create control events which stop it
- make sure this control event is the first in the list
- select the "Finish" button on the ExitDialog
- add a SetProperty Published control event:
[AI_AUDIOFILE_UI] Stop 1
- make that this control event is the first in the list
- Repeat the last two steps for FatalError and UserExit dialogs
This custom action will not run if the installation does not use a
full UI.
Specify whether the audio file is looped or not
By default, the audio file will run in a loop, restarting when it reaches the end. You can make sure the file is only played once by using an installer property:
- Go to Custom Actions Page
- under "InstallUISequence" show the "Begin" standard action
- under it, create a new "Property Set with Formatted" custom action
- set the "Property Name" field to AI_AUDIOFILE_OPTIONS
- set the "Formatted Text" field to LOOP_OFF
Some of the supported audio file formats are: .MP3, .WAV, .WMA and MIDI.
The file will not be played if its content does not match its
extension (for example a .WMA file renamed to .MP3).