小编MrC*_*nOp的帖子

在Mojave上更新为Xcode 10.1,现在我的应用程序总是要求使用麦克风

我正在运行AVAudioSession,我怀疑它正在激活麦克风请求,但我只将它用于声音和音乐.在macOS Mojave上运行Xcode 10.1 Simulator时,为什么要激活访问麦克风的请求?我还没有写过一行甚至要求访问它.我的应用程序不需要访问它也不需要它.这是播放音乐的代码:

AVAudioSession *title = [AVAudioSession sharedInstance];
[title setCategory:AVAudioSessionCategoryAmbient error:nil];
[title setActive:YES error:nil];


//MUSIC
NSString *path = [[NSBundle mainBundle] pathForResource:@"music_nature" ofType:@"mp3"];
NSURL *url = [NSURL fileURLWithPath:path];
titleMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:NULL];

titleMusic.numberOfLoops = -1;
[titleMusic setVolume:1.0];
[titleMusic play];
Run Code Online (Sandbox Code Playgroud)

如果我注释掉上面的代码,我将不再收到麦克风的请求.但后来我没有任何音乐.

示例项目:https://github.com/Coeur/StackOverflow53109911
(您需要macOS Mojave来重现该问题)

屏幕截图演示错误消息

xcode ios avaudiosession ios-simulator macos-mojave

15
推荐指数
1
解决办法
1068
查看次数

标签 统计

avaudiosession ×1

ios ×1

ios-simulator ×1

macos-mojave ×1

xcode ×1