Here is the code to play the sound programmatically in iphone
1. First include the AVFoundation.framework
2. second #import <AVFoundation/AVFoundation.h>
3. Last paste the following code where you want to play the song
1. First include the AVFoundation.framework
2. second #import <AVFoundation/AVFoundation.h>
3. Last paste the following code where you want to play the song
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/song.mp3", [[NSBundle mainBundle] resourcePath]]];
AVAudioPlayer *av = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
[av play];
[av setVolume:1.0];
0 comments:
Post a Comment