rafizan46
Posts: 62
Joined: Wed Mar 29, 2017 2:45 pm

Play audio file on Install Execution stage using checkbox

Hello, how do i play audio file on install execution stage when user check on checkbox? and not play audio file when user not check on checkbox? I want make an audio as to notify user when download progress is finished. Any help would be appreciated :)
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: Play audio file on Install Execution stage using checkbox

Hello,

In order to achieve that, we need to know the following:

- first of all, a checkbox has a property assigned to it. This property stores the checkbox state and it can have two values:

"CheckBox" when the checkbox is checked.

"" when the checkbox is not checked.


Now, in order to achieve what you want, you can proceed as it follows:

- go to "Dialogs" page and add a checkbox to one of your dialogs.

- go to "Custom Actions" page and add a "PlayAudioFile" custom action with sequence by pressing the "Add custom action with sequence" button which is placed to the right side of the custom action's name.

- schedule it under "Install Execution Stage" by simply drag and dropping it.

- under "Execution Stage Condition", use a condition as it follows:

THE_CHECKBOX_PROPERTY = "CheckBox"

where the "THE_CHECKBOX_PROPERTY" is the property assigned to your checkbox. By default, the property is called:

CHECKBOX_1_PROP

This can be seen (and modified) by going to "Dialogs" page, selecting your checkbox and checking the right pane (the "Properties" pane). There you can see a section called "Property" where you can define the checkbox property name.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rafizan46
Posts: 62
Joined: Wed Mar 29, 2017 2:45 pm

Re: Play audio file on Install Execution stage using checkbox

Its weird i didn't get this working. My checkbox property name is IMAGECHECKBOX_1_PROP_1. So, under Execution Stage Condition, i put IMAGECHECKBOX_1_PROP_1 = "CheckBox" as suggested. But it doesn't play any audio on finish execution when I check the checkbox. When I put this, IMAGECHECKBOX_1_PROP_1 = CheckBox [without double apostrophe], the audio was played, but it played with and without checking the checkbox. Is there something wrong. The check box is position inside Progress Dialog, where the user can check or uncheck the checkbox while waiting the installation to finish / go to Finish Dialog.
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: Play audio file on Install Execution stage using checkbox

Hello,

This sounds like a strange behavior. The condition you have used is correct, the file should be played.

From what I understand, you want to play the file when a button is pressed, am I right? If that is the case, please have a look on the following article which explains how that can be achieved:

How to play an audio file during install

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rafizan46
Posts: 62
Joined: Wed Mar 29, 2017 2:45 pm

Re: Play audio file on Install Execution stage using checkbox

Yes, I want play the audio file on finish execution notifying the user that the download is finished when the user check the checkbox. If the checkbox is unchecked, there will no any notify sound.
rafizan46
Posts: 62
Joined: Wed Mar 29, 2017 2:45 pm

Re: Play audio file on Install Execution stage using checkbox

Its like "Notify Me" checkbox.. not a button.
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: Play audio file on Install Execution stage using checkbox

Hello,

After further testing this, it seems that it is not possible to have the "PlayAudioFile" custom action as a custom action with sequence, scheduled on the Wizard Dialogs Stage (in this case, after the Finish Dialogs Stage).

I have added this improvement on our TODO list and hopefully this will be available starting with a future version of Advanced Installer.

Unfortunately, as for this moment, I am afraid I can not give you any estimation on when this will be implemented. Thank you for your understanding.

However, after further investigating this, I was able to develop a custom action which can play your MP3 file at the end of the installation (during the "Finish Dialogs Stage").

In order to implement this, you can proceed as it follows:

1. Add the MP3 file as a temporary file in the "Files and Folders" page.

2. After doing so, double click on it and:

a. check the "Do not remove the file when setup ends"
b. copy its property (simply copy what is written in the "Property" field)

3. Go to "Custom Actions" page

4. Add a "PowerShellScriptInline" custom action, with sequence, by pressing the "Add custom action with sequence" button which is placed to the right side of the custom action's name.

5. Schedule it during the "Finish Dialogs Stage"

6. In the "Parameters" field, copy the following line:

Code: Select all

-path "[THE_PROPERTY_YOU_HAVE_EARLIER_COPIED]"
7. The script should look like this:

Code: Select all

# Block for declaring the script parameters.
Param($path)

# Your code goes here.

Add-Type -AssemblyName PresentationCore
Add-Type -AssemblyName PresentationFramework



$song = New-Object System.Windows.Media.MediaPlayer
$song.Open($path)
$song.Play()

Start-Sleep -s 3
$Song.Stop()
You can modify the seconds (depending on how much you want the song to be played.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Feature Requests”