我设法创建了包含动画的应用程序。但是我希望通过添加我从网上下载的.wav文件使其脱颖而出并更有趣。我希望声音在动画期间播放。只在一个月前开始编码,所以任何帮助都将深受赞赏
答案 0 :(得分:0)
您可以使用AVAudioPlayer
只需创建一个方法并将其连接到您的按钮或动画
-(void) playLoopingMusicInApplication {
AVAudioPlayer *audioPlayer;
// set the pathForResource: to the name of the sound file, and ofType: to AAC preferrably.
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"fileName" ofType:@"WAV"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
player.delegate = self;
//infinite
player.numberOfLoops = -1;
[player play];
//[player release];
}
希望这有帮助!