2009-08-18 7 views

Répondre

2

Voici some sample code qui vous montre comment jouer un fichier audio sous Mac OS X (10.5 et versions ultérieures). Il utilise l'API AudioQueue.
Regardez le code aqplay.

0

En supposant que vous souhaitiez lire de la musique préenregistrée, essayez d'utiliser QTMovieView. Il y a un tutoriel sur comment l'utiliser here.

1
-(void) playAlarmSound 
{ 
    // Get the filename of the sound file 
    NSString *path = [NSString stringWithFormat:@"%@%@", 
         [[NSBundle mainBundle] resourcePath], 
         @"/alarm.wav"]; 

    // Declare a sound id 
    SystemSoundID soundID; 

    // get a URL for the sound file 
    NSURL *filepath = [NSURL fileURLWithPath:path isDirectory:NO]; 

    // Use audio services to create sound 
    AudioServicesCreateSystemSoundID((CFURLRef) filepath, &soundID); 

    // Use audio services to play the sound 
    AudioServicesPlaySystemSound(soundID); 
}