Re: Best Strategy to Control iTunes

2009-04-03 Thread has
On Apr 1, 2009, at 8:15 PM, Ammar Ibrahim wrote: I'm afraid I'm new and don't quite understand, do you recommend I use appscript? I'm biased, of course, but yeah, it's probably the best choice. It's more powerful and reliable than Scripting Bridge, can be used in background threads so

Re: Best Strategy to Control iTunes

2009-04-02 Thread Ammar Ibrahim
On Thu, Apr 2, 2009 at 12:07 AM, Bill Bumgarner b...@mac.com wrote: On Apr 1, 2009, at 2:04 PM, ammar.ibrahim wrote: Right now, I'm more confused than I was, hehe. My question is: Why would I care about thread safety? Assuming that everytime I communicate with iTunes I create a thread and

Re: Best Strategy to Control iTunes

2009-04-02 Thread Kyle Sluder
On Thu, Apr 2, 2009 at 9:22 AM, Ammar Ibrahim ammar.ibra...@gmail.com wrote: To sum up, you mean I should use osascript in a separate process? How can I achieve that, and how can I have this separate process communicate back to the main process? NSTask creates child processes. The general

Re: Best Strategy to Control iTunes

2009-04-01 Thread has
Michael Ash wrote: On Tue, Mar 31, 2009 at 3:57 PM, Luca C. luca.pazzere...@gmail.com wrote: 2009/3/31 Ammar Ibrahim ammar.ibra...@gmail.com If I want to add a track to iTunes, I need to make sure iTunes is responsive. Are you sure it is that important? Actually, if you run an AS script

Re: Best Strategy to Control iTunes

2009-04-01 Thread Sean McBride
On 4/1/09 12:25 PM, has said: ObjC-appscript is almost entirely thread-safe. You'll need to watch when using methods that rely on the Carbon Process Manager (some initializers, -isRunning) as the PM APIs don't appear to be thread- safe itself Looking through Processes.h, it would appear that all

Re: Best Strategy to Control iTunes

2009-04-01 Thread has
On Apr 1, 2009, at 3:57 PM, Sean McBride wrote: On 4/1/09 12:25 PM, has said: ObjC-appscript is almost entirely thread-safe. You'll need to watch when using methods that rely on the Carbon Process Manager (some initializers, -isRunning) as the PM APIs don't appear to be thread- safe itself

Re: Best Strategy to Control iTunes

2009-04-01 Thread Ammar Ibrahim
On Wed, Apr 1, 2009 at 12:15 AM, Nate Weaver natewea...@xtechllc.comwrote: On Mar 30, 2009, at 5:44 PM, Ammar Ibrahim wrote: - It's known that if any dialog is open in iTunes it freezes any communication through the scriptable interface, how can I detect that and put all my messages in

Re: Best Strategy to Control iTunes

2009-04-01 Thread Ammar Ibrahim
On Wed, Apr 1, 2009 at 2:25 PM, has hengist.p...@virgin.net wrote: Michael Ash wrote: On Tue, Mar 31, 2009 at 3:57 PM, Luca C. luca.pazzere...@gmail.com wrote: 2009/3/31 Ammar Ibrahim ammar.ibra...@gmail.com If I want to add a track to iTunes, I need to make sure iTunes is responsive.

Re: Best Strategy to Control iTunes

2009-04-01 Thread Luca C.
2009/4/1 Michael Ash michael@gmail.com No, don't do this. AppleScript is not safe to use outside the main thread. If you must run AppleScript asynchronously, either spawn a subprocess to run it or, better yet, don't use AS at all but send Apple Events in some other way, such as with

Re: Best Strategy to Control iTunes

2009-04-01 Thread Ammar Ibrahim
On Wed, Apr 1, 2009 at 10:21 PM, Luca C. luca.pazzere...@gmail.com wrote: 2009/4/1 Michael Ash michael@gmail.com No, don't do this. AppleScript is not safe to use outside the main thread. If you must run AppleScript asynchronously, either spawn a subprocess to run it or, better

Re: Best Strategy to Control iTunes

2009-04-01 Thread Luca C.
2009/4/1 Ammar Ibrahim ammar.ibra...@gmail.com On Wed, Apr 1, 2009 at 10:21 PM, Luca C. luca.pazzere...@gmail.com wrote I didn't realize the unsafety of NSAppleScript - so I have been quite lucky, because my usage of applescript in non-main threads haven't caused me any problems.

Re: Best Strategy to Control iTunes

2009-04-01 Thread Bill Bumgarner
On Apr 1, 2009, at 2:04 PM, ammar.ibrahim wrote: Right now, I'm more confused than I was, hehe. My question is: Why would I care about thread safety? Assuming that everytime I communicate with iTunes I create a thread and have the communication happen from there, even if it's blocking and

Re: Best Strategy to Control iTunes

2009-03-31 Thread Luca C.
2009/3/31 Ammar Ibrahim ammar.ibra...@gmail.com My application will be adding/removing tracks to iTunes. I will not be controlling playback or anything like that, it's mainly to manipulate the database and playlists. If you want that, you may want to use NSAppleScript. If I want to add a

Re: Best Strategy to Control iTunes

2009-03-31 Thread Nate Weaver
On Mar 30, 2009, at 5:44 PM, Ammar Ibrahim wrote: - It's known that if any dialog is open in iTunes it freezes any communication through the scriptable interface, how can I detect that and put all my messages in a queue, so that when iTunes is responsive, I can send my messages?

Re: Best Strategy to Control iTunes

2009-03-31 Thread Michael Ash
On Tue, Mar 31, 2009 at 3:57 PM, Luca C. luca.pazzere...@gmail.com wrote: 2009/3/31 Ammar Ibrahim ammar.ibra...@gmail.com If I want to add a track to iTunes, I need to make sure iTunes is responsive. Are you sure it is that important? Actually, if you run an AS script wich, say, opens with

Best Strategy to Control iTunes

2009-03-30 Thread Ammar Ibrahim
I'm currently developing an App in iTunes, and I'm new to Cocoa and the entire Mac development world. So far, things are looking great. I have few questions, about which is the best strategy to follow in order to accomplish some tasks. This is a special purpose app, in a controlled environment. *

Re: Best Strategy to Control iTunes

2009-03-30 Thread Luca C.
Hi Ammar, 2009/3/30 Ammar Ibrahim ammar.ibra...@gmail.com I'm currently developing an App in iTunes, and I'm new to Cocoa and the entire Mac development world. So far, things are looking great. I have few questions, about which is the best strategy to follow in order to accomplish some

Re: Best Strategy to Control iTunes

2009-03-30 Thread Mark Suman
For issue 1: I use NSWorkspace to handle this. Someone more knowledgeable than me might be able to answer your more detailed questions. When I launch my app, I check the sharedWorkspace to see if com.apple.iTunes is already running. If not, I launch it. For issue 2: There is a nifty framework

Re: Best Strategy to Control iTunes

2009-03-30 Thread Ammar Ibrahim
* Communcation with iTunes - What's the best interface to use? There are many approaches but if you don't tell us what are your purposes we can't tell you wich approach is the best for your use. However, i suggest googling for ScriptingBridge. My application will be