Re: NSMovie init
Re: NSMovie init
- Subject: Re: NSMovie init
- From: Jeff Martirano <email@hidden>
- Date: Fri, 9 May 2003 16:21:48 -0700
Yes, I solved my probably shortly after posting my email, and was about
to respond when you guys replied with your fantastic answers.
All I can say is that the Cocoa community is great, and thank you very
much for your help.
Jeff
On Friday, May 9, 2003, at 03:46 PM, Douglas Davidson wrote:
On Friday, May 9, 2003, at 3:01 PM, Jeff Martirano wrote:
I'm having a bit of trouble creating an NSMovie pointer. It works
fine when I init with an outside URL with "initWithURL:[NSURL
URLWithString:@"http://someserver.com/movie.mov"] byReference:YES];"
or with a hard coded path to a local file:"initWithURL:[NSURL
URLWithString:@"file:///path/to/directory/movie.mov"]
byReference:YES];"
but I can't make it work when trying to play a movie that I will
bundle with the application. I've copied the movie into the project
and tried to reference it with "initWithURL:[NSURL
URLWithString:@"file://movie.mov"] byReference:YES];" and other
variations, but that doesn't seem to work.
For images, I typically use "[[NSImage alloc]
initByReferencingFile:[[NSBundle bundleForClass:[self class]]
pathForImageResource:@"image.png"]];" but NSMovie doesn't seem to
have a comparable init method.
First, you probably don't want to use URLWithString: to create file:
URLs from paths; there's a special method, fileURLWithPath:, that's
designed to do that correctly. Second, you don't really need
specialized methods like pathForImageResource: to look up resources in
your bundle; you can use the standard NSBundle methods like
pathForResource:ofType:. Putting it together, you can do something
like
initWithURL:[NSURL fileURLWithPath:[[NSBundle bundleForClass:[self
class]] pathForResource:@"movie" ofType:@"mov"]]
Now, you don't really need the bundleForClass: call either, unless
you're doing this from a framework; if your movie is in your
application's bundle, you can simply this by just writing [[NSBundle
mainBundle] pathForResource:@"movie" ofType:@"mov"].
Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.