gpt4 book ai didi

ios - 模拟器中的 AVAusioSession pty 错误

转载 作者:可可西里 更新时间:2023-11-01 06:06:35 26 4
gpt4 key购买 nike

我有一个简单的代码可以通过 AVAudioPlayer 播放声音

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"beep"
ofType:@"mp3"]];

self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
self.player.volume = 1;
[self.player prepareToPlay];

我的异常断点将停止在 prepareToPlay 并且控制台日志写道:

ERROR: AVAudioSessionUtilities.h:111: GetProperty: AudioSessionGetProperty ('prp?') failed with error: 'pty?

点击 2 次通过此断点后,应用程序不会崩溃。这只发生在模拟器中。有什么建议吗?

最佳答案

以下代码可能会有帮助。

NSURL *url;
url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/beep.mp3", [[NSBundle mainBundle] resourcePath]]];
self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
self.audioPlayer .delegate = self;
[self.audioPlayer prepareToPlay];
[self.audioPlayer play];

关于ios - 模拟器中的 AVAusioSession pty 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27748377/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com