• 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: performance drop when calling applescript during performdrag
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: performance drop when calling applescript during performdrag


  • Subject: Re: performance drop when calling applescript during performdrag
  • From: Thomas Bauer <email@hidden>
  • Date: Sun, 11 Jun 2006 18:50:35 +0200

Hi!

Thanks for your quick reply. You saved me a lot of time that I would have spent trying out
things in the wrong direction.


However I found (a somewhat weird) solution that still delivers an acceptable user expierience
and allows me to reject the tracks right before adding.


During performDragOperation I just create a NSTimer that fires only once after 0.05 seconds and takes the information for adding as userinfo. This obviously delays the applescript call long enough until iTunes woke up again and everything runs surprisingly smootly that way. I know it is probably kind of bad style but at least it works and is somewhat creative, isn“t it? ;-)

thanks a lot, kind regards
tom

On Jun 11, 2006, at 12:02 PM, Andrew Farmer wrote:

On 11 Jun 06, at 02:24, Thomas Bauer wrote:
In my application I am calling an applescript using NSAppleScript and NSAppleEventDescriptor (because I have to pass a parameter to the script). My application is accepting dragged iTunes songs and i need all the information about the song there including the duration (which is unfortunately not prestent in the pasteboard information). So I call the applescript which gets the "Track ID" of the dragged iTunes track and returns the duration in seconds.

However, if I call the same script during a "performDragOperation", the script takes 10 seconds, giving my application a spinning ball. Unfortunately this is what i need, because i would like to check the total duration immediately, disallowing dragging another song if the total duration exceeds a certain value.

iTunes may be running an auxiliary event loop for file drag operations, so it can't receive Apple Events properly. (Remember that it's still a Carbon application, so it does all sorts of odd things.)


There's really no easy way around this one. Your best bet is waiting for the drag to complete before checking. You could also try reading the track data out of the iTunes XML library, although that's likely to be a rather slow operation with large libraries.

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >performance drop when calling applescript during performdrag (From: Thomas Bauer <email@hidden>)
 >Re: performance drop when calling applescript during performdrag (From: Andrew Farmer <email@hidden>)

  • Prev by Date: Re: Class won't allocate
  • Next by Date: Re: Enforce Min Count in Core Data To-Many relationship
  • Previous by thread: Re: performance drop when calling applescript during performdrag
  • Next by thread: If Functions
  • Index(es):
    • Date
    • Thread