IOS Play mp3 sound

//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];

Comments

Popular posts from this blog

LINUX Move and copy files using SSH

PHP Predefined Variables

Java : Variables Declaring