I can't really tell you what is going wrong. I have done quite a bit with FileMaker and AppleScript, including running Unix shell scripts. But I have very seldom had to use GUI scripting (except some messing about with changing fonts). I just don't think you need to. All you really need to do is give the Insert Quicktime a FileMaker syntax path, no AppleScript needed for that.
Set Variable [ $mp3; "moviemac:/Macintosh HD/Users/fej/Music/iTunes/iTunes Music/Alison Krauss/Forget About It/Maybe.mp3" ]
Go To Field [ mp3 container ]
Insert Quicktime [ $mp3 ]
So you'd just need to take your POSIX path, add the "moviemac:" prefix, and the drive name. Which you can get via the Get (SystemDrive) function. It returns it in the syntax: /Macintosh HD/
So you'd need to remove the trailing slash, since your Unix path likely starts with a slash.
No, it works perfectly as is.
Thanks very much... of course this was the right way to do it. :)
FMP 11, iMac, OS 10.6.3
I have imported my iTunes files into a FMP programme, including the file path or location which looks like this:
I can play the song directly using an 'open URL' connection, but that moves the control to iTunes, and I want to play a (list of) song(s) within FMP and controlled by FMP.
So I am trying to reformat the file path to suit QuickTime
After reformatting the file path I can use the method proposed in your message, but I don't seem to get the right format; my latest effort was:
"file:/Iomega HDD/albumdisk/ALBUMS/Music/Abba/The Definitive Collection - Abba/1-01 People Need Love.mp3"
Do you see what I am doing wrong?
One thing that is wrong is that you have an "absolute" file path (beginning from the root of the hard drive), but a "relative" prefix. Try using "filemac:" instead of "file:".
There are various ways to play a sound file. Yes, on most Macs, just opening the file is going to launch iTunes and play it, in a big window; because iTunes is the default application for such things, unless you change it. Which is a system-wide change, applying to all music. You cannot easily do this from FileMaker, nor really should you.
If you use AppleScript, you have more options and more control. It is possible to tell iTunes to play it in a minimized window, or even hide the window.
Also, as you say, you can specifically use Quicktime instead, via AppleScript. Quicktime also opens it in a little window, but it's a cute little window, with pause icon, etc..
Quicktime supports both a URL path, which you can target via an Open URL path (just like FileMaker). Or you can use AppleScript's regular open with a Mac path (with colons). Since you have a URL path (Location_URL is my FileMaker field):
set url_path to cell "Location_URL" of current record
tell application "QuickTime Player"
open URL url_path
play document 1
"activate" brings the little QT window to the front, so you know it's there. Alternatively you could not do that, or even make it non-visible. But then you'd need little AppleScript buttons to Pause, Stop, Close, Quit, whichever.
If you want total background operation, with no icon in the Dock, etc., there is, on newer Macs, a built-in audio player via command line: afplay
You can run this from FileMaker, via AppleScript's do shell script command.
It requires a proper Unix POSIX path (which is similar to, but not the same as a URL path).
do shell script "afplay '/System/Library/Sounds/Hero.aiff' &> /dev/null &"
The redirect to dev/null is needed, or it ties up FileMaker while it's playing; since FileMaker started it by running the AppleScript.
Once it starts a music file, it is going to continue until it's finished, or you stop it. You can do this by killing the afplay process.
do shell script "killall afplay"
Thank you for your reaction and excellent suggestions.:smileyhappy:
My original question is no longer relevant, as the problem is solved in the QT approach.
I couldn't find any track of "afplay", although I bought this iMac only six weeks ago.
I settled for the Quick Time player and it works perfectly.
I must confess that I never took time to learn AppleScript, but it seems a good investment to learn it, as it offers much flexibility and possibilities for controlling what is going on.
Yes, the little QT window looks and works nicely.
It is a Mac command line tool. It is in the /usr/bin/ folder. But since the /usr folder is not visible in the regular hard drive Finder window you'll not see it. You can use the Finder menu, Go to folder, /usr
There are tons of command line tools in the /bin/ and in /sbin/ folders, which do all kinds of things. Be careful not to move them.
AppleScript can run them via: do shell script "command line"
FileMaker can run AppleScript, via Perform AppleScript
This extends the power of FileMaker, when the situation calls for it; either internet access (curl, ftp), file manipulation, text processing (awk, grep), etc.. 'afplay' is a later addition, to the basic Unix commands (and ones later added by Apple).