Cocoa Newbie needs help…

rhale1

KU Mac Geek
OK. I need some Cocoa help. I want to have a movie play when the window opens, via some code or NSTimer. What should I do. Keep in mind I need semi step-by-step directions. Thanks.

:)
 
I'll asume Java for the mean time, but I can post ObjC instructions too (it's prretty much the same).

Drag an instance of NSMovieView to ur window in Interface Builder(it's the icon that looks like a big Q for quicktime). Hook it up to your controller object. In your controller code, create an instance of NSMovie view like so

Code:
String pathToMovieFile ="..."
NSMovie movie = new NSMovie(new java.net.URL("file://" + pathToMovieFile), false);

then take your NSMovieView object and call this

Code:
movieView.setMovie(movie);

I'd set this all up this method
Code:
public void awakeFromNib()
{
   //above code
}

then if you want to play your movie, just call start(this) and stop(this).

HTH,
F-bacher
 
I'll post the simple HOW-TO when I get back to my dorm (a female friend of mine is kicking me out - stupid sleep ;)) It's almost exactly the same process.

F-bacher
 
Here we go...

The IB stuff is exactly the same. In your header file of your controller you shade have your NSMovieView object declared (I'm sure you've already know how to do this). In your Controller.m (what are these called again?), you should have a method as so:

Code:
-(void)awakeFromNib
{
   NSMovie* movie = [[NSMovie alloc] initWithURL:[[NSURL alloc] initWithString:@"pathToFile"] byReference:NO];
   [movieView setMovie:movie];
   [movie start:self];
}

That should be it.

HTH,
F-bacher

NOTE: I suck at garbage collection (hence I use Java), but I believe my allocated NSURL object should be sent an autorelease message.
 
Back
Top