0
我是最新的Xcode版本。我正在使用以下代码重新启动我的背景音乐。但是这些代码不会重新启动背景音乐。AVAudioPlayer没有重新启动bg音乐?
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"game" ofType:@"wav"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
[player stop];
player.currentTime = 0;
[player play];
什么是不工作的意思?你有错误吗? – thegrinner
我没有收到错误。但是每次当我点击开始按钮时,音乐都会一直播放。 –