play mp3 sound

by nik 4. May 2009 04:55

//need to add: AVFoundation.framework

#import <AVFoundation/AVAudioPlayer.h> 

NSBundle *mainBundle = [NSBundle mainBundle];

NSURL *url = [NSURL fileURLWithPath:[mainBundle pathForResource:@"game" ofType:@"mp3"] isDirectory:NO];

 

AVAudioPlayer *gameSoundTrack = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];

[gameSoundTrack prepareToPlay];

[gameSoundTrack play]; 

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen