Custom Alert Sounds that play instantly?

Hey Guys,
Trying to think of a good solution here and wondering if anyone has done anything similar.
In this system we have taken over for a new client, they have a file where a guy in the warehouse scans various barcodes that go into fields to mark shipments going out. The functionality of it all seems to work pretty well, the original developer did a great job.

The issue they have currently however, is that the script validates the data coming in from the barcode to make sure it is the right format, and if it is correct it uses the 'Beep' script step to make a noise. However as they say the guy doing the scanning is not very 'computer literate' and sometimes he will start scanning away while he is in another application or has the window minimised. When this happens the windows computer makes an alert noise to say something isn't right, which is of course the same noise that the FileMaker Beep script step uses.

So they say at this point he will have been happily scanning away hearing the beeps thinking everything is all good but of course it is not. If I try to put some custom sounds in interactive containers with auto play and use functionality like LuminFire's fmSoundPlayer, the sounds take way too long to render and even if I put a 10 second pause on the script (which is obviously way to long as he is scanning across fields rapidly) the sound won't even play before the script resumes.

Can anyone think of a solution to this (using technology rather than drilling into the user that they need to ensure they are in the right window, as that has been tried)?

If possibile, a simple JS function can do the trick.
Just place a webviewer outside the visible area of the layout, using some HTML as simple as this:

<html>
<body>
	<script>
		function playAudio(url) {
			new Audio(url).play();
		}
	</script>
</body>
</html>

Then, from the FileMaker script just invoke the function passing the URL of the notification sound as a parameter, using the Perform JavaScript in Web Viewer script step.
You can obviously hardcode the URL into the JavaScript, but this approach is way more flexible (e.g. in addition to a successful scan, you can play a different sound for an incorrect barcode) for little to no cost.

note: I'm not a webdev so I don't know if there's some workaround, but this approach does NOT support local files, only remote resources: you can't play an audio file from the document folder but you have to reference a remote resource (e.g.https://assets.mixkit.co/sfx/preview/mixkit-sci-fi-click-900.mp3)

It may be a basic approach and not what anyone would consider ideal, but thinking about the cost/benefit of attempting to customize the signal the user hears from FileMaker, I would probably start by simply have FileMaker output 2 beeps for each scan, something that should let the user distinguish feedback from your app from feedback from the OS telling the device is not sending data to the intended application.

There is nothing that I know of that will let you know if a FileMaker window looses focus. Perhaps you could try an on timer script selecting the window. But all in all, if the user is not paying attention, perhaps FileMaker could even not be running at all and he would start scanning, so the different audio feedback sounds like the right way to go, but I would start with something simple before getting into something custom.

1 Like

If you use MBS Plugin, maybe try
App.PlaySystemSound
Plays a system sound with given name

Your thinking is inline with my thinking as well. The client seems very keen on a specific sound but my thoughts had been that if the sound the computer makes when the window has lost focus is the same as the success sound, we could just make it that if it makes no sound (other than the beep the handheld scanner makes it self) then you know it is successful, and any computer noises means something is wrong. Two beeps would also be a way around it

I had been looking at this as an option as well. We currently don't use MBS in this system.

Well, if needed, I could provide a simple function to just play an audio file.

Or you use AVPlayer for macOS/iOS and WMFP functions for Windows.

create a container field
format it as interactive check "Start Playback automatically"
in you script load that record with the Audio file in the container (new window)
give it a Pause of the length of the audio stream ..

1 Like

runsound.fmp12 (284 KB)

2 Likes

That is the method that I outlined in the post. It doesn't work as it takes more than 10 seconds to play the one second sound. I imagine this is due to the network as it's hosted locally but it takes so long to render on their file that unless I pause it for 20 seconds it won't play, and the guy is scanning pretty fast.

@MonkeybreadSoftware A function would be great, but it does seem like your plug in might be an easier solution than my current idea of using javascript to program a sine wave sound

//try to copy sound file into global container field

BS - still loads with major delay if WAN accessed - sorry!!

I like this.

Understood that latency is an issue on WAN, and also understood/assumed that complexity is avoided by all of us.

But, still wondering:

What if a startup script were to export a FMP file to a local directory? That FMP file could contain just one table with one record, with the container data needed to be the sound file that gets played.

The startup script would then set up a dynamically set external Data Source path to the exported FMP file, thus making its data available on the relationship graph. Then, maybe the rest of the script and the one layout it uses could still be the same, i.e. they would still live in the main solution file? The difference is that, presumably the container data would be pulled in from local disk, and would not traverse the network, hence cutting back on the latency factor.

The trickiest parts I see would be writing the code to get the export path and the data source path in place correctly, and then also perhaps setting up permissions on the exported file so that it auto-logs in without needing any prompts, but without needing to know the main file's creds.

(Having a dynamic data source would assume something like v.16 or later.)

2 Likes

EDIT: I posted a better version below if the sounds needs to be played repeatedly in quick succession.

Here's a technique similar to one I use in production for alerts. It uses the webviewer audio.play() approach. You can replace the audio with whatever sound you want (as base64).

It plays pretty dang quickly, but I'm not sure if it'd be quick enough for someone with a barcode scanner on a mission.

Play Sound.fmp12 (272 KB)

4 Likes

Yeah this is what I found. The file by LuminFire I mentioned in the original post uses that technique. When I downloaded the sample file and put my custom sound file in it, it played instantly. As soon as I put it on the hosted database it had the massive delay. Super annoying

Right after i posted that file above, i had another idea to allow concurrent sound playback by loading a couple audio elements at once. This would be good for a fast scanner.

I just tested hosted on FMS and it's pretty fast, but not blazing.

new version
Play Sound V2.fmp12 (268 KB)

3 Likes

it's flabbergasting that a global container field won't perform any better ..

If the system runs on a Mac, you could also invoke the "speak" script step for a very custom touch (you can type text, and it will read it aloud). This step is not cross-platform and works only on FMPro.

1 Like

This is actually a known behavior (and I believe acknowledged by Clay Maeckel). When a file is hosted, if you put a file in a global container field, it still uploads to the host.

You can observe this behavior with a network monitoring tool.

I had to work around this behavior in one of my systems where users wanted to add a bunch of photos at once and click save. When i tried global containers, thinking it would make the UX fast, it was super slow for each container. What I ended up doing was very similar to @steve_ssh 's suggestion above, where you export a local file to the temp directory and populate local containers. Then it passes the data to the hosted file via external data source when you click "save".

As for playing sounds from global containers, that's gonna be just as bad as non-global storage on a hosted file. :confused:

2 Likes

Josh

I'd recommending watching the FileMaker Pro temporary file folder on the client computer when using container fields. It is used a lot and would explain the network traffic.

This is another reason we stream FileMaker via workspaces, as all of this traffic takes place within the cloud and not between the user's computer and the Internet hosted server.

Regards
Andy

I had actually just made this exact function and then saw your comment (I think we must have found the same stack overflow question). However I've used yours as the sound you found was much better than mine. It is definitely the fastest of all the solutions I've attempted so far, but not sure if it's still fast enough.
I will test in their network next week and let you know, other wise I think the solution will be either two beeps or no beeps as people suggested earlier.