标签:des os io 文件 for ar amp log
[playButton setEnabled:YES];
NSError *playerError;
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[[[NSURL alloc] initFileURLWithPath:mp3FilePath] autorelease] error:&playerError];
self.player = audioPlayer;
player.volume = 1.0f;
if (player == nil)
{
NSLog(@"ERror creating player: %@", [playerError description]);
}
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategorySoloAmbient error: nil];
player.delegate = self;
- (void)playPause
{
//If the track is playing, pause and achange playButton text to "Play"
if([player isPlaying])
{
[player pause];
[playButton setTitle:@"Play" forState:UIControlStateNormal];
}
//If the track is not player, play the track and change the play button to "Pause"
else
{
[player play];
[playButton setTitle:@"Pause" forState:UIControlStateNormal];
}
}
xcode 中用AvAudioPlayer播放mp3文件,布布扣,bubuko.com
标签:des os io 文件 for ar amp log
原文地址:http://www.cnblogs.com/HuiLove/p/3909852.html