0
嘿家伙如何让应用程序在按下按住/电源按钮后继续播放mp3。用户按下iPhone上的保持按钮后,如何保持音乐播放?
这里是我使用的准备AVAudioPlayer代码:
- (void)PrepareAudio:(int)index
{
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@",[_Audio objectAtIndex:Game]] ofType:@"mp3"];
NSURL *newURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];
MusicPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: newURL error: nil];
[newURL release];
[MusicPlayer setVolume: 1.5];
}
当我按下按钮播放这是代码:
- (IBAction)PushPlay: (id)sender
{
if(!MusicPlayer.playing)
[MusicPlayer play];
}
问候
卡洛斯巴尔