1. n1mda's Avatar
    Hi guys!

    I'm having some troubles setting up this pretty easy task. I want to use AVAudioPlayer to play a sound from the commandline. No fancy windows or such.

    The thing is, I need to use audioPlayerDidFinishPlaying in order to see if the sound has finished playing, but then I need to delegate the avaudioplayer to "self".

    But afaik, since I don't have any window or view "self" does not exist.

    How do I do this without the delegate?

    Code:
    #import "Playback.h"
    
    int main(int argc, char **argv)
    {
    	NSAutoreleasePool *autoreleasePool = [[NSAutoreleasePool alloc] init];
    	
    NSString *pathToMusicFile = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"mp3"];
    
    AVAudioPlayer * myMusic = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile] error:NULL]; 
    
    [myMusic prepareToPlay];
    [myMusic play];
    
    }
    Oh and btw, I use toolchain with 2.2.1 sdk under linux.
    2009-05-07 05:29 PM
LINK TO POST COPIED TO CLIPBOARD