fmSoundPlayer is a FileMaker demonstration file that shows you to play a sound on command. Playing a sound in FileMaker on command is a little trickier than you might think. First, there is no simple “Play Sound” script command in FileMaker. There are script commands to play movies…but that’s not the same thing.
Here is a description of the basic technique. First, you need a global container field in the table to be used as a utility to play the sound on script command. We called it gSoundPlayer. On the layout in the Inspector you must select this field and optimize for “Interactive content” and then check “Start playback automatically”. Normally, you do not want this set since as soon as you enter a record it would play the sound….annoying.
We also found it helpful to hide the field by entering a “1” in the “Hide object when” Inspector field Behavior area. Then drag the gSoundPlayer field into the header or footer of the layout so there is only one instance of it on a list view. This is critical to avoid multiple instances of the field on one layout that creates an issue where they try to all play simultaneously and ruins the sound quality.
The script to Play the sound moves the sound from the Sound container field to the global gSoundPlayer field. Upon doing so it will automatically play. Then the script waits for a few seconds for the duration of the sound if it can be calculated or 5 seconds if unknown or >= 10 seconds (wav files). It then clears the field stopping the sound play.
If you want to cut off or stop the sound early, the stop button does the following.
Pretty straight forward once you know the trick. Download the sample file at the end of the article.
You can use it to create your own sound collection and play them on demand.
If you wanted a modern hotel desk bell, maximize that sound and leave it open on an iPad.
When looking at the sample file, there is an easter egg when you play the gong or siren sounds. Enjoy!
(Note: The special effects are not visible on FileMaker Go since they are not applicable on iOS.)