Also, if you're just playing an MP3 file, look into using QTKit on the main thread. Should be very much simpler and Objective C.

On 7 Sep 2008, at 02:35, John Michael Zorko wrote:


Hello, all ...

I'm new to Cocoa, and i'm trying to launch a thread. Yet, the app bombs when I try, and the console says it's because the selector isn't implemented:

2008-09-06 18:23:30.919 XXX[2363:20b] SEL: playMP3StreamThread
2008-09-06 18:23:30.927 XXX[2363:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** - [NSThread initWithTarget:selector:object:]: target does not implement selector (*** -[XXXAppDelegate playMP3StreamThread])'

Yet, here it is -- i'm not understanding something obviously (the example I saw looked easy enough):

@implementation XXXAppDelegate

.
.
.

- (void)playMP3StreamThread:(Song *)streamToPlay
{
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        
// initialize a mutex and condition so that we can block on buffers in use.
        
        pthread_mutex_init(&myData.mutex, NULL);
        pthread_cond_init(&myData.cond, NULL);
        
OSStatus err = AudioFileStreamOpen(&myData, MyPropertyListenerProc, MyPacketsProc,
                                                                           
kAudioFileAAC_ADTSType, &myData.audioFileStream);
        if (err)
        {
                NSLog(@"AudioFileOStreamOpen error %d", err);
        }
        
        NSString *url = @"http://some_hostl/";;
        url = [url stringByAppendingString:streamToPlay.mp3];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
        
        if (connection)
        {
                receivedData = [[NSMutableData data] retain];
        }
        else
        {
                NSLog(@"can't connect to server");
        }
        
        [pool release];
}


- (void)playStream:(Song *)streamToPlay
{
        NSLog(@"playing mp3 stream %s", [streamToPlay.mp3 UTF8String]);
        
        // make sure current song play thread is stopped ...
        
        
        
        
        
        
        // start a new thread with the new song ...
        
[NSThread detachNewThreadSelector:@selector(playMP3StreamThread) toTarget:self withObject:streamToPlay];
}

What am I not grokking?  Any pointers would be appreciated ...

Regards,

John




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net

This email sent to [EMAIL PROTECTED]

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to