Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > CD Playing

CD Playing
Thread Tools
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
Jan 21, 2002, 12:05 PM
 
I need a way to play CD's from Cocoa. I'm hoping I won't have to go as low level as core audio or the carbon sound manager. I've found source code for going that route from the OmniGroup.

Thanks,
David

[ 01-22-2002: Message edited by: davecom ]
     
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
Jan 21, 2002, 07:14 PM
 
ok, i just tried it with nssound, doesn't work because it doesn't support sounds in aifc, i get "NSSound error: found AIFC form type in AIFF sound; cannot play these yet" -- yet... lol!

but what i've just tried that works is the following:

add the quicktime framework by choosing "project > add framework". now, import quicktime by adding this line to the head of your .m file:

<font face = "courier">#import <QuickTime/Movies.h></font>

the rest is simple: initialize a movie this way:

<font face = "courier">NSMovie *someMovie = [[NSMovie alloc] initWithURL:[NSURL fileURLWithPath:<PATH>] byReference:YES];</font>

where PATH is the full path to the file on the cd.
then, you can play it this way:

<font face = "courier">StartMovie([someMovie QTMovie]);</font>

simple, isn't it? three lines of code... ;-)

edit: i wasn't very specific; yes, i'm talking about audio.
and thinking about it: "import" doesn't count -- that makes it two lines...

[ 01-21-2002: Message edited by: seb2 ]
     
davecom  (op)
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
Jan 21, 2002, 08:42 PM
 
Originally posted by seb2:
<STRONG>ok, i just tried it with nssound, doesn't work because it doesn't support sounds in aifc, i get "NSSound error: found AIFC form type in AIFF sound; cannot play these yet" -- yet... lol!

but what i've just tried that works is the following:

add the quicktime framework by choosing "project &gt; add framework". now, import quicktime by adding this line to the head of your .m file:

&lt;font face = "courier"&gt;#import &lt;QuickTime/Movies.h&gt;&lt;/font&gt;

the rest is simple: initialize a movie this way:

&lt;font face = "courier"&gt;NSMovie *someMovie = [[NSMovie alloc] initWithURL:[NSURL fileURLWithPath:&lt;PATH&gt;] byReference:YES];&lt;/font&gt;

where PATH is the full path to the file on the cd.
then, you can play it this way:

&lt;font face = "courier"&gt;StartMovie([someMovie QTMovie]);&lt;/font&gt;

simple, isn't it? three lines of code... ;-)

edit: i wasn't very specific; yes, i'm talking about audio.
and thinking about it: "import" doesn't count -- that makes it two lines...

[ 01-21-2002: Message edited by: seb2 ]</STRONG>
Thanks so much. I really appreciate it. Now how can I take control of this movie. Such as knowing the position in the file that the playing is at etc.

Thanks again,
David
     
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
Jan 22, 2002, 04:52 PM
 
Originally posted by davecom:
<STRONG>Thanks so much. I really appreciate it. Now how can I take control of this movie. Such as knowing the position in the file that the playing is at etc.

Thanks again,
David</STRONG>
i fear i don't know that much more about this. stopping, rewinding and finding out the duration is some simple stuff i can do, but quicktime is a lot of ugly pure c stuff. no idea how to find out where it is playing. sorry.

actually, the first time i had a look at movies.h was about a week ago.

whenever i have problems with carbon stuff and the like, i -- cough -- call my brother. ;-)
he's way brighter than i am.
     
davecom  (op)
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
Jan 22, 2002, 04:55 PM
 
Originally posted by seb2:
<STRONG>

i fear i don't know that much more about this. stopping, rewinding and finding out the duration is some simple stuff i can do, but quicktime is a lot of ugly pure c stuff. no idea how to find out where it is playing. sorry.

actually, the first time i had a look at movies.h was about a week ago.

whenever i have problems with carbon stuff and the like, i -- cough -- call my brother. ;-)
he's way brighter than i am.</STRONG>
I found a lot of info at the Quicktime API pages online. It's a bit cryptic, but I think I'll manage. Thanks for all your help.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:46 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2