Problem with Cocoa on Java.
Problem with Cocoa on Java.
- Subject: Problem with Cocoa on Java.
- From: Antonio Di Ferdinando <email@hidden>
- Date: Wed, 2 Jul 2008 17:27:24 +0100
Hi all,
I'm quite fresh of this mailing list (and to cocoa), so please accept
my apologies if there is something wrong with the subject.
I have a problem using Cocoa in my Java application.
In the big picture, I am developing an application that needs to
display contents on a continuous basis, in a way similar to those
advertisement screens that is possible to find in metro stations, etc.
The application contains a (Java) class that takes a path as input
parameter and plays the movie found at the location of the path. This
action is repeated on average every 40 secs, and paths are obtained
dynamically (thus I cannot force the class to play this or that movie).
Internally, in the Java class i define an applescript script and an
NSAppleScript that executes the script. The excerpt of code for the
execution of the applescript script is below ('script' is the
applescript script I use to start the application and play the movie):
NSAppleScript myScript=new NSAppleScript(script);
NSMutableDictionary errors=new NSMutableDictionary();
System.out.println("Starting script execution");
myScript.execute(errors);
System.out.println("script executed");
if(errors.count()>0)
System.out.println("errors: "+errors.toString());
In my tests, I am using VLC or QuickTime as players.
When I use VLC, the applescript script I use is:
String script = "tell application \"VLC\" \n" +
"\t OpenURL \""+path+"\" \n" +
"\t play \n" +
"\t next \n" +
"\t --quit application \"VLC\" \n" +
"end tell \n";
When I use QuickTime Player, the script I use is:
String script="tell application \"QuickTime Player\" \n"+
"\t open file (\" "+path+" \" as POSIX file) \n"+
"end tell \n"+
"delay 15\n"+
"tell application \"QuickTime Player\" \n"+
"\t quit \n"+
"end tell";
What apparently happens, and is my problem, is that at a certain point
the NSAppleScript does appear to return, and thus the Java class is
insensitive to the subsequent calls. In other words, looking at the
code snippet above: on a normal execution, the application would print
on screen:
Starting script execution
script executed
while on a 'problematic' execution what I have is only:
Starting script execution
and the application ceases to work.
I don't know whether this is an issue related to the actual
applescript script or the execution of the NSAppleScript itself, and
can't work out a way to get rid of this. The OS is 10.5.4, and the
Java use is the latest released for Mac but compiled with Java 5
standards.
Does anybody know what's wrong with this? Or, alternatively, other
solutions?
Thanks in advance.
Antonio.
http://san.ee.ic.ac.uk/~diferdin
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden