Comment voulez-vous jouer n'importe quel type de musique dans l'objectif-c (pas iphone sdk), et comment arrêteriez-vous la musique?Jouer de la musique? - Objectif C
Merci, Kevin
Comment voulez-vous jouer n'importe quel type de musique dans l'objectif-c (pas iphone sdk), et comment arrêteriez-vous la musique?Jouer de la musique? - Objectif C
Merci, Kevin
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.
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.
Depuis que vous avez tagué la question xcode
, jetez un oeil à NSSound et Apple's Audio Overview.
Jetez un oeil à Getting started with Audio & Video - iPhone Dev Center
-(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);
}