我完全按照阅读文件中的说明操作,但出于某种原因,在我的应用程序中,每次我按下UIButton对应的代码来播放声音“[soundA play];应用程序只是崩溃而没有任何详细信息错误描述除了lldb。我正在使用Finch,因为它使用OpenAL播放音频,我需要使用OpenAL作为我正在制作的应用程序类型,因为AVAudioPlayer或System Sounds不能用于我正在制作的内容。是我正在使用的代码。
主要文件:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
soundFactory = [[FIFactory alloc] init];
engine = [soundFactory buildSoundEngine];
[engine activateAudioSessionWithCategory:AVAudioSessionCategoryPlayback];
[engine openAudioDevice];
soundA = [soundFactory loadSoundNamed:@"1.caf" maxPolyphony:16 error:NULL];
soundB = [soundFactory loadSoundNamed:@"2.caf" maxPolyphony:16 error:NULL];
soundC = [soundFactory loadSoundNamed:@"3.caf" maxPolyphony:16 error:NULL];
soundD = [soundFactory loadSoundNamed:@"4.caf" maxPolyphony:16 error:NULL];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
- (IBAction) PlaySoundA {[soundA play];}
- (IBAction) PlaySoundB {[soundB play];}
- (IBAction) PlaySoundC {[soundC play];}
- (IBAction) PlaySoundD {[soundD play];}
@end
标题文件:
#import <UIKit/UIKit.h>
#import "FISoundEngine.h"
#import "FIFactory.h"
#import "FISound.h"
@interface ViewController : UIViewController {
FIFactory* soundFactory;
FISoundEngine* engine;
FISound* soundA;
FISound* soundB;
FISound* soundC;
FISound* soundD;
}
@end
任何帮助将不胜感激!谢谢!
答案 0 :(得分:0)
声音播放器很可能无法找到您的声音文件。尝试右键单击音频文件并在finder中选择视图。确保文件实际上在项目目录中,而不是