Re: realize Audio CD Player
Re: realize Audio CD Player
- Subject: Re: realize Audio CD Player
- From: Brian Christensen <email@hidden>
- Date: Mon, 16 Feb 2004 11:37:58 -0500
On Feb 16, 2004, at 9:19 AM, Emmanuel Verlynde wrote:
How make a program to play audio cd tracks, with easily
pause/resume/stop/previous/next/fforward/fbackward options?
Wich library or tools can i use?
Quicktime? NSSound? ...
I'm assuming that since audio CD tracks are represented as AIFF files
you could use QuickTime to play them. Pause, resume, stop, previous,
and next should be very easy to implement. Fast forward/backward will
probably be a bit trickier. Assuming you know the path where your CD is
mounted at (you can probably obtain it through NSWorkspace's
mountedRemovableMedia), you can enumerate through its contents to get a
list of the tracks. Write some kind of AudioTrack class to wrap around
the QuickTime functions to play them. It should look something like
this:
#import <QuickTime/QuickTime.h>
@implementation AudioTrack
- (id)initWithContentsOfURL:(NSURL *)url
{
self = [super init];
if (self)
{
movie = [[NSMovie alloc] initWithURL:url];
movieData = [movie QTMovie]; // this instance variable is of
type Movie
}
return self;
}
- (void)dealloc
{
[movie release];
[super dealloc];
}
- (void)play
{
if (!isPlaying)
{
StartMovie( movie );
isPlaying = YES;
}
}
- (void)stop
{
if (isPlaying)
{
StopMovie( movie );
isPlaying = NO;
}
}
@end
(The usual disclaimer for Mail.app created code applies.)
I don't know off the top of my head if calling StopMovie() resets its
time back to zero, so you'll have to look into that for implementing
your pause and resume methods. If it does reset it, you can use
GetMovieTime() to save the time position when you pause, and then
SetMovieTime() to restore it when you resume. For fast forward/backward
you'll probably want to look at SetMovieRate(), it should let you
increase the playback speed to give you the desired "fast" effect. You
should also catch QT errors somewhere; look at the documentation for
more information on that.
FYI, there's also a quicktime-api list at
http://lists.apple.com/ if
you need any more specific help with the QuickTime end of things. I
suggest getting acquainted with the documentation first though.
/brian
_______________________________________________
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.