As far as I can see (and through searches on the Internet), the Java I'm using to invoke the AppleScript shouldn't be a problem:
LOG.info("about to execute [script=" + script + "]");
NSAppleScript myScript =
new NSAppleScript(script);
NSMutableDictionary errors =
new NSMutableDictionary();
LOG.info("executing script");
NSAppleEventDescriptor results =
myScript.execute(errors);
int errorCount = errors.count();
if (errorCount > 0) {
throw new AppleScriptErrorException(errors);
}
return results.stringValue();
If anyone has any experience of this kind of behavior or has any thoughts on what might be going on, I would greatly appreciate it. If there's any more detail I can give, please let me know.
Thanks in advance,
Zuhayr Khan
AppleScript:
set debug to "
"
set debug to debug & time string of (current date) & " about to tell iTunes
"
tell application "iTunes"
set debug to debug & time string of (current date) & " about to open file
"
open "Macintosh HD:Users:zuhayrkhan:Music:Test.mp3"
set debug to debug & time string of (current date) & " issued open file
"
with timeout of 1 second
set debug to debug & time string of (current date) & " about to get playerState
"
set playerState to player state as string
set debug to debug & time string of (current date) & " got playerState:" & playerState & "
"
if (playerState = "stopped") then
set debug to debug & time string of (current date) & " is stopped
"
repeat until playerState = "playing"
set debug to debug & time string of (current date) & " about to delay:" & playerState & "
"
delay 0.1
set debug to debug & time string of (current date) & " done delay:" & playerState & "
"
set playerState to player state as string
set debug to debug & time string of (current date) & " playerState now:" & playerState & "
"
end repeat
end if
set debug to debug & time string of (current date) & " about to stop "
stop
end timeout
return debug
end tell