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
我沒有收到錯誤。但是每次當我點擊開始按鈕時,音樂都會一直播放。 –