我使用AVFoundation framework
播放声音。在文件的开头,我有:应用程序崩溃时播放声音
#import <AVFoundation/AVAudioPlayer.h>
而AVFoundation framework
已正确添加到我的项目中。然而,当我使用此代码播放声音,应用程序崩溃:
NSString *pathForBgMusicFile = [[NSBundle mainBundle] pathForResource:@"ClenchedTeeth" ofType:@"mp3"];
NSURL *bgMusicFile = [[NSURL alloc] initFileURLWithPath:pathForBgMusicFile];
AVAudioPlayer *bgMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:bgMusicFile error:NULL];
[bgMusic play];
有谁知道如何解决这一问题?提前致谢!
你能显示崩溃日志吗? – rishi
你的应用程序做其他事情吗?如果你用这个做一个虚拟应用程序,它会崩溃吗? ARC还是手动内存管理?以上代码的 –
似乎很亮。 – samfisher