Re: Play a song with QTMovie
Re: Play a song with QTMovie
- Subject: Re: Play a song with QTMovie
- From: Stephane Sudre <email@hidden>
- Date: Tue, 26 Jun 2007 11:44:17 +0200
On 26 juin 07, at 10:59, Dani . wrote:
Hi! I've been reading every message about how to play a song with
cocoa, and finally I can't find anything that works. I've made a
simple code, and I want to know what I am doing wrong. Thanks
#import <Foundation/Foundation.h>
#import <QTKit/QTMovie.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *src = @"/Users/bittercold/Desktop/deadbolt.aiff";
QTMovie *song = [[QTMovie alloc] initWithFile:src error: NULL];
[song play];
[pool release];
return 0;
}
I think the key is in the difference between asynchronous and
synchronous.
When you call play, it continues immediately and does not wait for the
song to be played.
What you may want to do is to:
- have a run loop
- install a notification observer for the end of the playback and stop
the application a this point.
As I usually do this through a QTMovieView, I can't confirm just using
[QTMovie play] can work for a song.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden