Blaze Posted October 3, 2005 Posted October 3, 2005 On PC it's easy to use a track and CD Drive field to have a script launch a specific track from cd - On Mac I'm not sure how to go about this since the CD drive / name is not fixed as it is on PC - how would I script this on Mac, OSX 10.4 FMP 8 Advanced Thanks for the help, Blaze
Fenton Posted October 3, 2005 Posted October 3, 2005 (edited) You could use AppleScript on a Mac, in a Perform AppleScript step. All modern Macs have iTunes installed and registered to play any music file. So all you have to do is open the file. You can check to see if a particular CD is mounted first. There are also cross-platform plug-ins (which I haven't tried) http://www.24usoftware.com/PlaySound AppleScript code: --tell application "FileMaker Developer" set theCD to cell "CD_Name" of current record set theSong to cell "Song_Name" of current record set theExt to cell "Extension" of current record --end tell tell application "Finder" set theDisks to name of disks -- names of mounted disks as list if theDisks contains theCD then set songFile to theCD & ":" & theSong & "." & theExt if exists file songFile then open file songFile -- This will launch iTunes and play the song end if else beep display dialog "It's not here!" buttons {"Cancel"} default button 1 with icon caution -- or stop end if end tell Edited October 3, 2005 by Guest Added ":" to file path
Blaze Posted October 3, 2005 Author Posted October 3, 2005 Thanks for the reply Fenton! When I run the applescript I get an object not found followed by Unknown Error: -1728 Having zero experience with apllescript - I don't even know where to begin! I entered your coded verbatim with the substitution "FileMaker Pro Advanced" for FileMaker Developer" as I am on 8 pro advanced but other than that I'm not sure if some of the codes were literal names of coded variables? Thanks again for the help!
Fenton Posted October 3, 2005 Posted October 3, 2005 (edited) Oops. I forgot the ":" (folder separator). I made a little CD player with FileMaker. It uses iTunes. There's a couple of AppleScript script files I included, so you can view them with Script Editor. One uses the Finder to open the file. The other tells iTunes explicitly to play the song. Comes to the same thing more or less. I had a slight problem getting the iTunes window to stay at the back. I couldn't keep it from flashing. It's just an Apple thing. There may be (probably are) better methods. There are AppleScripters who write lots of stuff for iTunes. I also rewrote the error messages so that FileMaker could show them in its own dialog. BTW, you don't usually need or want: tell "FileMaker Pro" etc. lines inside a FileMaker Perform AppleScript script step, as it's not necessary. So "FileMaker Developer", "FileMaker Pro Advanced" doesn't matter. In fact those lines are commented out with --AppleScript comment marks. I only leave them there so I can write/edit scripts in the Script Editor app; then I comment out the lines before I copy/paste into FileMaker. You don't want to actually write AppleScripts in the FileMaker Perform AppleScript dialog. It's too primitive. Just for fun, I added another AppleScript to eject whatever audio CD. CD_Player.zip Edited October 3, 2005 by Guest Added Eject script
Blaze Posted October 3, 2005 Author Posted October 3, 2005 Man Thanks for sharing your time and know how with me- One remaining question - will the CD name & song always have to be entered manually or is there anyway to automate the lookup of those items so that they don't always have to be entered. I'm sure there are apple scripts that perform lookups on CDDB etc . but then how to get those entered into fields - and if there is no entry available default to the syntax of "Audio CD,1 Audio Track.aiff" I'll thumb around with it a bit more myself - I'm just a bit under the gun for time on this and no real time to adopt AppleScripting skills (not to mention the fact I'm doing all of the migration on a borrowed mac not connected to the internet). Anyway thanks again for your help and time!!!
Fenton Posted October 3, 2005 Posted October 3, 2005 OK, here's one more example. This one won't even let you enter the names. It creates them from the CD, if you don't have the CD yet. Otherwise it finds the CD. I don't have any problem with names. I don't know why that is. Maybe I've inserted all my (few) CDs already. Maybe iTunes just goes and gets them. I have iTunes set to launch on inserting a CD, so I can't tell. But I always see song names on the CDs. CD_Player2.zip
Fenton Posted October 6, 2005 Posted October 6, 2005 This is another version of my CD Player. I changed the way it calculates the track# and name, so they are now separate fields. I also changed it so rather than hiding iTunes when it plays, it just minimizes the iTunes window as a little "control" window. You can then use that to do things, or click back into FileMaker. The included "Play with iTunes" AppleScript still has the various options for what to do with the iTunes window, but commented out. CD_Player3.zip
Blaze Posted October 7, 2005 Author Posted October 7, 2005 For Some reason I can only get this script to activate some of the time - it has problems seeing theCD or myCD I've been pounding my head on this one for a few days - It will sometimes work for reasons which I can't discern and other times wont work for reasons I can't discern. I'm baffled Some kind of breakdown when I run it in Script editor I get a syntax error at the "count record of first database" line in the tell application section. The error reads "expected class name but found identifier"
Fenton Posted October 7, 2005 Posted October 7, 2005 I don't know why it's not working. It works every time for me. iTunes goes and gets the song names, using Gracenote. You can see this in the iTunes window, which comes to the front automatically when I put a CD in. This is set in the System Preferences panel, the CDs & DVDs pane: When I insert a music CD: Open iTunes. I don't know if this is the default (I would think so). As far as errors in Script Editor, there's something else I should explain (but was hoping I wouldn't have to, as I've done it many times before). When you run AppleScripts in Script Editor you need the lines: tell application "FileMaker Pro" -- whatever script contents end tell Otherwise you'll get an error as soon as you hit any FileMaker specific language, like "count record of first database". But you don't need (or want) those lines active when you run a script inside a FileMaker Perform AppleScript step. Anything at the top level of a script inside the Perform AppleScript step is automatically directed to FileMaker. You only need: tell application "FileMaker Pro" blocks if you're inside some other apps tell block. I write my AppleScripts to avoid this situation wherever possible. So what I do is -- comment out those lines inside FileMaker. That way if I want to take the script out again and test with Script Editor, all I have to do is remove the dashes. Then, when the test is complete, I --comment them out again and copy/paste into the FileMaker Perform AppleScript step. In FileMaker looks like: --tell application "FileMaker Pro" script contents --end tell BTW, I'm using iTunes 5.0.1, which is the latest. But this should work in most earlier versions also. I believe there's a preference setting somewhere to automatically play an inserted CD. It used to be in the Quicktime preferences (long ago), but I couldn't find it. Apple keeps moving these things.
Recommended Posts
This topic is 6989 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now