gpt4 book ai didi

ios - 音频播放和录制不适用于 iOS 10

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:02:52 24 4
gpt4 key购买 nike

我无法在 iOS 10 中播放任何音频文件,即使是默认的键盘敲击声也无法播放。

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord  error:&sessionError];

在视频录制中,(我使用的是 AVCaptureConnection),有时会录制声音,有时不会。

我正在使用 LLSimpleCamera 录制视频。

有人可以推荐我吗?

问候

最佳答案

我在使用 LLSimpleCamera 时遇到了同样的问题,使用这段代码

@property(readonly, strong, nonatomic) LLSimpleCamera *camera;
//...
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
[[self camera] startRecordingWithOutputUrl:path didRecord:^(LLSimpleCamera *camera, NSURL *outputFileUrl, NSError *error)
{ /*do something*/ }

当我在调用 startRecordingWithOutputUrl: 之前更早地设置类别时 问题没有出现。因此,在 setCategory: 之后放置一些代码并检查。我知道这不是一个“真正的”解决方案,但经过 6 小时的努力,它对我有用。

无法重现此代码的问题:

[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];

/* do some UI-related stuff, hide buttons, show bars, some animation */

[[self camera] startRecordingWithOutputUrl:path didRecord:^(LLSimpleCamera *camera, NSURL *outputFileUrl, NSError *error)
{ /*do something*/ }

附言仅在 iPhone 7 上转载

关于ios - 音频播放和录制不适用于 iOS 10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40548139/

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