Jump to content

Trigger applescript from calculation?


This topic is 6832 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Can I trigger an applescript from a calculation field?

Short explanation of what I am trying to do.

I have a database of local bands that have played my club.

I have many of their demo songs in iTunes.

I would like to have a field in the database that will search iTunes for their band name, and return a list of the tracks available in itunes from said band.

Is this even possible?

Thanks

Link to comment
Share on other sites

Thank you for the reply.

I downloaded and installed shell, but after that, i am lost.

Forgive me, but i am not very advanced in filemaker or scripting.

Can you give me more direct instructions?

Thanks

Link to comment
Share on other sites

I don't think this really needs to be a question about using a calculation to automatically launch an AppleScript. Yes, it's possible, either using the Shell plug-in and an AppleScript (or using BruceR's AppleScript plug-in).

I would think it's more an AppleScript question. I would run it in a FileMaker Perform AppleScript step, using a button.

There are a lot of AppleScripts written already for iTunes. I just looked at Doug's AppleScripts:

http://www.dougscripts.com/itunes/

and found one called "Search, Shuffle, Play" which does much what you want. (You can remove the "shuffle" line.)

It uses a dialog however, which you don't need, as FileMaker already has the Artist name which you'd want.

It takes a list of all tracks found for the Artist and creates a new playlist on-the-fly, then plays it. Personally I already have my tracks in playlists with the artist name, so that's unnecessary.

So, in my case, I'd just look for the playlist containing the criteria I sent from FileMaker. This is simple. I can see however ways you could use AppleScript with iTunes to do this more intelligently. But this is the simplest:

--tell application "FileMaker Developer"

set searchArtist to cell "Artist" of current record

--end tell

tell application "iTunes"

set mySearchList to {}

set theLibrary to library playlist "Library"

set thePlaylist to 1st item of (playlists whose name contains searchArtist)

if thePlaylist is {} then

(display dialog "Could not find Artist." buttons {"Cancel"})

else

play thePlaylist

end if

end tell

You might also want a couple more buttons, running a Perform AppleScript step (no real need for a script)B)

tell application "iTunes" to pause

tell application "iTunes" to stop

Link to comment
Share on other sites

Thanks for your reply.

I have a similar script already that launches iTunes and plays songs of the current artist similar to what you suggested.

Not all of the artists in my database have songs in iTunes, and the goal was to be able to tell from the database record (without having to switch to iTunes) if there were songs of that artist in iTunes, and if so, what are they called.

It may be more complicated than the payoff is worth.

Darron

Link to comment
Share on other sites

Well, the AppleScript has to look to first, then it either finds something or it doesn't. If it finds something it plays it immediately. It doesn't even switch to iTunes. If it doesn't find anything, it either displays a dialog or it doesn't; that's up to you.

How long it takes to find out one way or another is going to be same whether you play it immediately or not, whether it's run by a calculation or a button. The speed is mostly determined by how well organized your iTunes playlists are; ie., whether it can just look in the playlist names or whether it must search every track.

The longer script that looks in each track name, then creates a new playlist, could be modified to go through all your FileMaker artist names, look for them in iTunes, and create new playlists for them if necessary, as a batch operation. That's what I'd do if my playlists were not organized already. (I don't have that much music.)

The only way it's going to know from FileMaker whether the artist has songs is if you keep and synchronize a FileMaker file with your iTunes library. There is a solution named "iGotta" which does this. But that may be, as you say, more complicated than the payoff is worth.

Link to comment
Share on other sites

  • 2 weeks later...

This topic is 6832 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.