Playing MP3 from Cocoa

Moderator
Posts: 592
Joined: 2002.12
Post: #1
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
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Just use QuickTime with straight C. QTValuePak has an example that can play an MP3.
Quote this message in a reply
Moderator
Posts: 592
Joined: 2002.12
Post: #3
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.
Quote this message in a reply
Tycho
Unregistered
 
Post: #4
Since Objective C is a superset of C, I wouldn't think it would be too hard. There's not really any "integration" involved.
Quote this message in a reply
Oldtimer
Posts: 832
Joined: 2002.09
Post: #5
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]
Quote this message in a reply
quillbit
Unregistered
 
Post: #6
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]
Quote this message in a reply
Komick
Unregistered
 
Post: #7
I found this yesterday. Hope it's helpful.

http://developer.apple.com/samplecode/Sa...Player.htm
Quote this message in a reply
Post Reply