AVAudioPlayer没有重启bg音乐?

时间:2015-06-04 07:30:04

标签: ios objective-c xcode6 avaudioplayer

我在最新的Xcode版本上。我使用以下代码重新启动背景音乐。但是这些代码没有重新启动背景音乐。

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];

2 个答案:

答案 0 :(得分:1)

要使用AVAudioPlayer,您需要对它进行强有力的引用。尝试将播放器设置为控制器的属性,然后使用$userId = $dbh->lastInsertId();

答案 1 :(得分:0)

将AVAudioPlayer声明为.h文件。

相关问题