10 Replies Latest reply on Mar 20, 2012 2:14 AM by disabled_Rob_2

    Play external audio file through script in FM

    SamPatterson

      Title

      Play external audio file through script in FM

      Post

      I have a database which has records of audio files which live on our network.  One of the fields in the database is the filepath for each audio file.  I would like to create a script which will play the audio file which is named in the filepath field.

      I do not want to put the audio into a container field as this database has over 40k records and will only get larger.

      I have tried the Send Event script step and i can get that to open the VLC media player, but I then have to go back to filemaker and copy the path from the filepath field.  Is there a way to automate this whole proces without having to go back and manually copy the file path?

      With the Send Event script step, I can get it to open text documents or spreadsheets with no problem.  It doesn't seem to work the same for an audio file.

      A typical path  in the filepath field would be something like:  d:\library\audio\nature sounds\AP01_01_01.wav

      The filepath field is set up as a text field.

        • 1. Re: Play external audio file through script in FM
          philmodjunk

          I do not want to put the audio into a container field as this database has over 40k records and will only get larger.

          Try inserting or importing these files into container fields, but use the "store by reference" option so that you store only the file path to the files. It would take some trial and error to get it to work, but I suspect you can use a replace field contents step to move the filepaths from the current field into the container field, formatted to work within the container field.

          The secret behind this is that you can manipulate the data stored in a "by reference" container field via Repalce field contents or Set Field just as though it is a text field instead of a container field. You may want to insert one sound file "by reference" manually and then examine the text stored in the container field to figure out the format that you'll need to make this work. (getasText can display the contents of the container field as text.)

          • 2. Re: Play external audio file through script in FM
            SamPatterson

            I tried inserting it into a container field and nothing happens.

            I have had a bit of iffy success using a Send Event Script step.   However, logging out and back in on the computer seems to destroy whatever happens to make the VLC player play the file.

            According to VLC, I should be able to use "vlc  filename" to open and play the file.  So the calculation looks like this:

            "vlc "&filepath

            filepath=field name with the path to the audio file.

            As I said, I get this to work, but then the next time I log in, I get a message that says "The file "vlc" could not be found and is required to complete this operation.  If i try to put the entire path it says that "C:/Program" can't be found.  Evidently this is because you cant have spaces in these calculations/commands.

            It's extremely frustrating to get this to work only to lose it because you've logged out.

            • 3. Re: Play external audio file through script in FM
              philmodjunk

              I tried inserting it into a container field and nothing happens.

              Exactly how did you try to do this?

              As a test, click on a container field and use Insert QuickTime to insert a reference to your audio file into the container field. The click on the field and try to play back the sound.

              Insert QuickTime only inserts files by reference so all such inserted files must remain in the location where they were when you inserted and the file name cannot be changed.

              • 4. Re: Play external audio file through script in FM
                SamPatterson

                I inserted the filepath through Insert File and selected "store only as reference to file."

                If I use the Insert Quicktime, it seems to be putting the media there because the file size increases.  Also the field appears blank until I click on it several times.

                Further, I have over 40k records in this database, and there doesn't seem to be a way to put in the pathnames inserted as a quicktime through either a calculation, look-up etc.

                So inserting as a QT seemed to be less preferable than creating a script that would play the file.

                • 5. Re: Play external audio file through script in FM
                  philmodjunk

                  Insert File won't work. Insert QuickTime should. It does not insert a copy of the file according to FileMaker help, only a reference to the file.

                  The fact that the file appears empty when sound files are inserted in this manner is a valid concern. Some developers use conditional formatting to create what appears to be an icon that is only visible when there is a reference inserted into the ocntainer field.

                  It is possible to move the file paths from a text field into such a container field, but the file path must be modified to use the correct syntax.

                  With a container field loaded via Insert QuickTime, Go TO field with the select/perform option is a one step script to play the sound.

                  • 6. Re: Play external audio file through script in FM
                    SamPatterson

                    The Insert Quick Time still isn't doing it for me.  I can find no way to Insert the QTs at one fell swoop.  The only thing I'm finding that works is to do it one at a time -- which isn't practical given the fact that I have over 40,000 records in this database.  This was the reason I was trying to develop a script that would take the filepath and open either VLC or QT and open and play the file.

                    I did try making a one-step script using Go To Field:

                        Go to Field[Select\perform; SFX::pathcontainer]

                    I only get it to play occasionally (and not very loudly even though audio is all the way up) and every time it freezes FM and I have to force quit it.

                    • 7. Re: Play external audio file through script in FM
                      philmodjunk

                      Is Your install of quick time up to date? Just need to rule that possible issue out.

                      Don't know why it would freeze FileMaker on you here.

                      If you can get Quick Time to work, there's a way to use the data in the fields you already have to set up the references in the container field in a batch operation--something that I've already mentioned in this thread, but there's no point in going there if you can't get the sound files to play effectively from the container field.

                      There are three other ways that you can try for opening the sound file:

                      Open URL and Send Event--which you've already tried, and you may be able to get a webviewer to open and play the sound file if you can construct a URL expression that successfully finds and opens the sound file. I've opend PDF files this way from a PDF stored in a container field so the curretn file path you have in a text field should be a starting point for setting that up.

                      • 8. Re: Play external audio file through script in FM
                        SamPatterson

                        Ok, I'm back on this.  I still have a few issues:

                         

                        1.  If I Insert Quicktime the "control bar" disappears. So, if i start playing a sound, I can't stop it.  I can't find anything in conditional formatting or anywhere else which would stop bar from disappearing or allow me to stop the file before it's finished playing.

                        2.  In a previous post, you said that it was possible to get these all inserted as QTs but i've had no luck with this either.  So far, it's been one at a time.  In a previous post you said, "It is possible to move the file paths from a text field into such a container field, but the file path must be modified to use the correct syntax."  What is the correct syntax?  My files are all located in a directory on our network like: G:\library\editing\sfx_library.   Is there something else which should be done to it?

                         

                        • 9. Re: Play external audio file through script in FM
                          philmodjunk

                          If I Insert Quicktime the "control bar" disappears.

                          Not having inserted audio or movie files myself, I'm suprised to learn this. I would have expected click on or hoverin over the container field would bring back the control bar. Anybody out there know what to do about that?

                          It's also possible to use a web viewer to view movie files, and the URL expression set up in it can construct the needed reference from the data in your container field or your text field with the filepath. (Just gave you an alternative to using a container field.)

                          In a previous post, you said that it was possible to get these all inserted as QTs but i've had no luck with this either.

                          Use Import Records | Folder with the "picture and movie files" option to import a folder of audio or movie files into a table in your database.

                          What is the correct syntax?

                          I suggest looking up Container Fields in Filemaker help where you can find examples of the filepaths created by the various insert options. You can also set up a calculation field where you use the name of your container field as the only term in its calculation. Specify Text as the return type and put it on your layout, sized several rows of text tall, next to your container field. You can then insert an audio file and this calculation field will show you the format of the file reference stored in the container field.

                          • 10. Re: Play external audio file through script in FM

                            Play external audio file through script in FM

                            posted by Sam Patterson

                            posted September 26, 2011 and, last edited February 10, 2012

                            Sam,
                            get FileMaker 24u SimpleSound plugin to PLAY PAUSE sounds referencing file paths AND does much much more.
                            A very simple productive plugin that expands audio capabilities in FileMaker. you can even play several sounds at one time. Check it out!! REALLY WORTH IT !!
                            H E A R T L A N D
                                 AMERICA

                            r o b  Jesus Land Tidd  l e w i s
                            architect visionary for hardware software