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 > Using Quicktime to play MP3s

Using Quicktime to play MP3s
Thread Tools
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Jan 28, 2002, 12:31 AM
 
Hello,

I am trying to alter a program I currently have that plays background music by looping an AIFF to loop an MP3 instead. I was wondering if anyone has any source of a way to effectively do this in cocoa in a very few number of steps? I am basically looking for something shorter than Apple's Quicktime MP3 player source or a way to create a FSSpec* from the cocoa API.

Thanks,
Jeff.
Spectral Class
"Shedding Light on Innovation"
     
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
Jan 28, 2002, 02:21 PM
 
Originally posted by Apocalypse:
<STRONG>Hello,

I am trying to alter a program I currently have that plays background music by looping an AIFF to loop an MP3 instead. I was wondering if anyone has any source of a way to effectively do this in cocoa in a very few number of steps? I am basically looking for something shorter than Apple's Quicktime MP3 player source or a way to create a FSSpec* from the cocoa API.

Thanks,
Jeff.</STRONG>
Sure, just use NSMovie. It accesses Quicktime. If you want to use the quicktime API, just call
[someNSMovie QTMovie]
You can also use NSMovieView to control it, or standard quicktime functions such as:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
someMovie = [[NSMovie alloc] initWithURL:[NSURL fileURLWithPath:<font color = orange>@"PATH GOES HERE"</font>] byReference:YES];
StartMovie([someMovie QTMovie]);
</font>[/code]
Remember to add the Quicktime Framework to your project and to import Movies.h (hence - #import &lt;QuickTime/Movies.h&gt
     
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Jan 30, 2002, 01:20 PM
 
That worked perfectly!

However, I did end up using NSMovieView to access the Quicktime API since it is a lot easier and OO. Unfortunately, it wouldn't allow me to loop the sound until I actually created a real NSMovieView (instead of just [[NSMovieView alloc] init]). Do you know of any clean way to have an invisible movie view? I could will probably play around some more and figure it out but if anyone has a good suggestion, it would be useful for future applications of this.

Also, is there any easy way of getting the amplitude of different frequency ranges at a given time? I am would like to have some OpenGL surfaces respond to the beat (iTunes visual-ish) in the game I am using this in (it is to run background sound).

Thanks,
Jeff.
Spectral Class
"Shedding Light on Innovation"
     
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
Jan 30, 2002, 06:00 PM
 
Originally posted by Apocalypse:
<STRONG>That worked perfectly!

However, I did end up using NSMovieView to access the Quicktime API since it is a lot easier and OO. Unfortunately, it wouldn't allow me to loop the sound until I actually created a real NSMovieView (instead of just [[NSMovieView alloc] init]). Do you know of any clean way to have an invisible movie view? I could will probably play around some more and figure it out but if anyone has a good suggestion, it would be useful for future applications of this.

Also, is there any easy way of getting the amplitude of different frequency ranges at a given time? I am would like to have some OpenGL surfaces respond to the beat (iTunes visual-ish) in the game I am using this in (it is to run background sound).

Thanks,
Jeff.</STRONG>
I think you could just set the position of the NSMovieView off the screen. Something like -500,-500 . As for the amplitude, you could do something like that using the pure Quicktime APIs, as I described before. I think the function was something like getBaseLevels. I don't remember exactly though, so see the Quicktime API
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Jan 30, 2002, 08:41 PM
 
I just made a window with (x,y,w,h) = (0,0,0,0). Works like a charm.

F-bacher
     
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Jan 31, 2002, 01:20 AM
 
Yeah, I ended up just choosing a window that exists for the entire duration of the program and made a subview with all zero dimensions. It worked perfectly.

I will take a look at the API and post back if I can find/create a synopsis of how to do it or have some other difficulty. The biggest problem is not knowing what parts of the QuickTime API apply to OS X since some parts are so old and use radically different types than those used by Cocoa.

Thanks for the help,
Jeff.
Spectral Class
"Shedding Light on Innovation"
     
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
Jan 31, 2002, 02:51 PM
 
Originally posted by Apocalypse:
<STRONG>Yeah, I ended up just choosing a window that exists for the entire duration of the program and made a subview with all zero dimensions. It worked perfectly.

I will take a look at the API and post back if I can find/create a synopsis of how to do it or have some other difficulty. The biggest problem is not knowing what parts of the QuickTime API apply to OS X since some parts are so old and use radically different types than those used by Cocoa.

Thanks for the help,
Jeff.</STRONG>
Everything in Movies.h in the Quicktime framework is of course current to OS X, including the return types. You may want to check that out. Do you have any idea of how to apply Cocoa threading technologies to using Quicktime functions. Such as starting a movie and keeping it in a different thread.
     
   
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 10:05 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