8 Replies Latest reply on Aug 30, 2015 9:50 AM by mgores

    Playing a sound file

    mgores

      I'm using FMA14. I was trying to come up with a way to play a sound file to be played as part of a script.  I created a global container field, put it on the layout and inserted the sound file.  I found the only way to get it to play was to have it stored as a reference and selected to play automatically.  Then it would play every time the layout was entered, but not necessarily when the script tried to call it.

       

      I finally got it to work by having the script insert the file, pausing for 12 seconds to let it play, then clearing the field.  It does work and solves the problem of having to go to each computer to insert the file into the global container, but it seems a bit "clunky".

       

      Is there a better way to call the sound file? 

        • 1. Re: Playing a sound file
          monkeybreadsoftware

          If you use MBS Plugin for this solution, you could check QTMovie functions:

          http://mbsplugins.eu/component_QTMovie.shtml

           

          there you can open audio file from container or file and play it in background.

          • 2. Re: Playing a sound file
            mgores

            Thanks Christian, I was trying to avoid having to buy plugins.  I saw an AVplayer script step, but couldn't figure out how to make it work.  For now my clunky script is making it work, just hoping for a little more elegant solution.

            • 3. Re: Playing a sound file
              fentonjones

              If you're on a Mac, you can use a built-in Unix command, afplay, calling via the "do shell script" command with AppleScript.

              It runs well, and has a few options. I tend to run it first to "kill" whatever may be already running, or you could end up with both running at once.

               

              Each of the below are running via Perform AppleScript.

               

              try

              do shell script "killall afplay"

              end try

               

              set unix_raw_file to cell "File_Path" of current record

              set unix_file to quoted form of unix_raw_file

              --try

                do shell script "afplay -q 1 " & unix_file & " &> /dev/null &"

              --end try

               

              The last part:  & " &> /dev/null &"

              is added so it releases FileMaker immediately. It your case you might now want it do that, so you could remove that; it works without it [ I'm not really a Unix guy, so can't tell you how exactly more details about that :-].

               

              I'm reading the Unix file path from a field (as I use this to play songs). In your case you could just add the Unix path manually (as it sounds like there's only one).

               

              You'd need to export the sound file to somewhere like the Temporary folder first. That should not take long with such a small file.

              • 4. Re: Playing a sound file
                etauscher@lhg.de

                In the Advanced Version you can create Layout Script Trigger….Trigger: Layout load

                This Trigger start the Script and your Sound will played.

                • 5. Re: Playing a sound file
                  mgores

                  Thanks Fenton, not much of a Unix guy either but keep meaning to learn it.

                  Will play around with that and see if I can make it work.

                  We do analyses and generate technical reports and this is for my "Job Tracking" solution.  I have a script that archives the pdf version of the report, attaches it to an email to the customer, then play a little clip (about 12 second .aif file) from a song.

                  The song part is just for fun.

                  • 6. Re: Playing a sound file
                    mgores

                    Actually I'm trying not to make it play when the layout loads, only when a script is executed.

                    • 7. Re: Playing a sound file
                      sam_oda

                      How about using a web viewer  to play sound?

                      You can export the sound to the temporary path, then play it by the web viewer.

                      I attatched a sample file.

                      • 8. Re: Playing a sound file
                        mgores

                        Hey Sam,

                         

                        That seems a bit clunkier.  The container field method is working.  I just formatted the global container field to autoplay then added these to my script.

                         

                        Go to Field [Soundfield]

                        Insert Audio/Video[Reference ; "filename.aif"] //container is set to auptoplay

                        Pause/Resume Script [ Duration (seconds): 15]

                        Set field [Soundfield ; ""]

                         

                        As long as the sound file is on the server it works for any user.  And since it clears itself out every time it won't play the sound unless the script is run.  Am thinking I throw several sound bites in and name them as 1.aif, 2.aif, 3.aif, etc  I can add a counter script and have it cycle through several different ones if I wanted.

                         

                        I was just thinking at first since there was some new (at least to me) AVPlayer script steps that there should have been a way to just play the file using a single step.