• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: New iTunes Track (AS DJ Script)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New iTunes Track (AS DJ Script)


  • Subject: Re: New iTunes Track (AS DJ Script)
  • From: Graff <email@hidden>
  • Date: Wed, 25 Feb 2004 12:16:37 -0500

On Feb 25, 2004, at 11:30 AM, Mr Tea wrote:

This from Greg Townsend - dated 24/2/04 11.55 pm:

Is there a way to use AS to determine when the track playing in iTunes
changes? I know you can use an idle handler, but I'd rather not have to
poll iTunes any more than is necessary


...and this from Matthew Smith - dated 25/2/04 2.10 am:

There's no other way, other than polling.


Which begs the question, is there anything inherently bad/inefficient/gauche
about using a stay-open applet with an idle handler for this sort of task?

I ask because I've never been entirely comfortable about leaving applets
ticking away around the place. I can't explain why. I just get a sort of
'you don't want to do that' feeling about it. (This happened, for example,
when I migrated to OS X, where 'folder actions' were at first unavailable,
then poorly implemented. I could easily have converted my folder action
scripts into stay-open applets to watch the folders for me, but preferred to
find other ways of doing what I needed.)

Is my dislike of stay-open applets irrational? (and would that dislike have
been irrational in OS 9 and earlier?) There are clearly contexts, like
monitoring track changes in iTunes, where nothing else will work, so should
I feel entirely comfortable about using a script like the 'AS DJ' reproduced
below, which checks iTunes every 3 seconds, or are there caveats and
potential pitfalls to consider... ?

There is absolutely nothing wrong with leaving a stay-open applet with an idle handler running for extended periods of time. Heck, it's pretty much the entire basis of Mac OS X!

Run Activity Monitor or go to the Terminal and run top. Take a look at just how many "stay-open" applications are open. Many of these are called daemons and they are what run your system. I just did that and I had 50 of them going, which is pretty typical. Of the 50 only 2 were running and the other 48 were sleeping. You never even notice all the daemons that are sleeping because when an application is sleeping it uses pretty much no processor time.

Memory is also pretty much a non-issue because when an application is sleeping it can be paged out to disk if the memory is needed in a pinch and then re-loaded when it comes active again. Mac OS X is pretty savvy with its memory management. The key is to keep your script relatively small but it takes some real effort to make an AppleScript so memory-intensive for this to matter much.

So I would say you shouldn't really worry about stay-open AppleScript applets that use an idle handler. So long as you have the idle handler poll at a decent interval you shouldn't even notice it. I like to keep my idle handlers 5 seconds or longer, 10 is a nice number if you don't need extremely immediate action. I don't think that you really need a response quicker than 5 seconds for a "currently playing" sort of script and increasing the idle time will cut CPU usage considerably.


- Ken
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: New iTunes Track (AS DJ Script) (From: Mr Tea <email@hidden>)

  • Prev by Date: Re: New iTunes Track (AS DJ Script)
  • Next by Date: Re: save a file via applescript
  • Previous by thread: Re: New iTunes Track (AS DJ Script)
  • Next by thread: Re: New iTunes Track (AS DJ Script)
  • Index(es):
    • Date
    • Thread