Playing MP3 from Cocoa
Can anyone point me in the direction of any sample code for playing an MP3 from Cocoa so I can add background music to my Chromacell game?
Thanks
Thanks
Just use QuickTime with straight C. QTValuePak has an example that can play an MP3.
Thanks for the suggestion.
How easy is it to integrate C code into the middle of Objective-C Cocoa code?
I was hoping to do everything in Objective-C Cocoa, but if it is not possible then I will have to follow this path.
How easy is it to integrate C code into the middle of Objective-C Cocoa code?
I was hoping to do everything in Objective-C Cocoa, but if it is not possible then I will have to follow this path.
Since Objective C is a superset of C, I wouldn't think it would be too hard. There's not really any "integration" involved.
Nope, just call the C functions as usual, as you would call any Obj-C method.
[SOURCECODE]
[myVar retain];
PlayMovieFromFile (your arguments go here);
[myVar release];
[/SOURCECODE]
[SOURCECODE]
[myVar retain];
PlayMovieFromFile (your arguments go here);
[myVar release];
[/SOURCECODE]
Just instantiate with [NSMovie initWithURL:byReference:] and pass [NSMovie QTMovie] to your QuickTime functions -- it's not quite toll-free bridged, but the access charge is very low. To wit:
[SOURCECODE]
// (use NSBundle to get your resource path here) ...
soundClip = [[NSMovie alloc] initWithURL: [NSURL fileURLWithPath: pathStringHere]
byReference: NO];
StartMovie([soundClip QTMovie]);
[/SOURCECODE]
[SOURCECODE]
// (use NSBundle to get your resource path here) ...
soundClip = [[NSMovie alloc] initWithURL: [NSURL fileURLWithPath: pathStringHere]
byReference: NO];
StartMovie([soundClip QTMovie]);
[/SOURCECODE]

