【问题标题】:AVAusioSession pty error in Simulator模拟器中的 AVAusioSession pty 错误
【发布时间】:2015-01-02 20:50:48
【问题描述】:

我有一个简单的代码可以通过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 并且控制台日志写道:

错误:AVAudioSessionUtilities.h:111:GetProperty: AudioSessionGetProperty ('prp?') 失败并出现错误:'pty?

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

【问题讨论】:

    标签: ios avaudioplayer avaudiosession


    【解决方案1】:

    以下代码可能会有所帮助。

    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];
    

    【讨论】:

      【解决方案2】:

      我认为这是模拟器特有的错误。设备上不会出现此错误。如果您想了解更多信息,请在此处进行讨论。 AVSpeechSynthesizer error AudioSession

      【讨论】:

        猜你喜欢
        • 2020-04-25
        • 2016-08-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-02
        • 2021-11-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多