最近,我将Xcode从5更新为6.4,模拟器没有发出任何声音,但发出了一些错误消息。最简单的代码不能很好地运行,该应用程序本身是在模拟器中启动的,但是没有音频,问题可能出在某些设置,因为我之前运行的所有代码和程序都运行良好。我使用的是全新的Mac mini,因此我从其他的旧代码中导入了这些代码。
如果有人遇到这样的问题,请帮助我!
错误是这样的:
2015-08-01 09:03:56.730 Testbutton [496:11659] 09:03:56.730错误:98:错误“!obj”试图获取默认输入设备的采样率
2015-08-01 09:03:56.731 Testbutton [ 496:11659] 09:03:56.731错误:100:获取音频输入设备采样率时出错:'!
obj'2015-08-01 09:03:56.731 Testbutton [496:11659] 09:03:56.731警告:230:输入设备为0x0;'(null)'
2015-08-01 09:03:56.731 Testbutton [496:11659] 09:03:56.731警告:234:输出设备为0x26;'AppleHDAEngineOutput:1B,0,1,2:
0'2015-08-01 09:03:56.732 Testbutton [496:11659] 09:03:56.732错误:296:错误'!obj'2015-08-01
09: 03:56.732 Testbutton [496:11659] 09:03:56.732错误:113:* * * NULL AQIONode对象
2015-08-01 09:03:56.732 Testbutton [496:11403] 09:03:56。
2015-08-01 09:03:56.732 Testbutton [496:11403] 09:03:56.732错误:> aq> 1595:失败(-66680);将停止(11025/0帧)
2015-08-01 09:03:56.736 Testbutton [496:11659] 09:03:56.736错误:703:无法制作UISound Renderer
代码是这样的:
// ViewController.m
// Testbutton
#import "ViewController.h"
@interface ViewController ()
{
AVAudioPlayer *_audioPlayer;
}
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Construct URL to sound file
NSString *path = [NSString stringWithFormat:@"%@/horn.wav", [[NSBundle mainBundle] resourcePath]];
NSURL *soundUrl = [NSURL fileURLWithPath:path];
// Create audio player object and initialize with URL to sound
_audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundUrl error:nil];
}
- (IBAction)buttonPressed:(id)sender {
[_audioPlayer play];
}
- (void)dealloc {
[audioPlayerPointer release];
[super dealloc];
}
@end
还有一个与此相关的头文件:
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@interface ViewController : UIViewController
{
AVAudioPlayer* audioPlayerPointer;
}
- (IBAction)buttonPressed:(id)sender;
@end
AVAudioPlayer需要有效的输入和输出才能进行设置。在真实的设备(内置这些东西)上,这不是问题,但是在MacMini上没有内置麦克风的模拟器中,这是一个问题。
如果您有麦克风,请尝试将其插入MacMini上的“ line in”端口(我在与这个非常相关的问题的答案的注释中找到了这种可能的解决方案)。确保也选择“ line-in”作为“系统偏好设置”中的输入。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句