gpt4 book ai didi

iphone - iPhone 中的 AVAudioPlayer prepareToPlay 回调

转载 作者:可可西里 更新时间:2023-11-01 05:00:20 24 4
gpt4 key购买 nike

在调用 prepareToPlay 后是否可以知道 AVAudioPlayer 何时准备就绪?

如果没有,是否有任何其他类提供此功能?

我想实现这样的东西:

- (void) prepare {
[audioPlayer prepareToPlay];
// Update UI to indicate that the audio is being prepared
}

- (void) onAudioReady {
// Update UI to indicate that the audio is ready
}

最佳答案

这个类可以帮助初始化音频,然后在您的 onAudioReady 方法中立即播放它。

https://github.com/nicklockwood/SoundManager

引用这篇文章:https://stackoverflow.com/a/10417762/1474080

您可以检查 [audioPlayer prepareToPlay] 的 BOOL 结果,以查看音频硬件是否已根据文档进行了初始化。如果结果为是,您可以生成一些 UI 供用户查看。

prepareToPlay Prepares the audio player for playback by preloading its buffers.

  • (BOOL)prepareToPlay Return Value Returns YES on success, or NO on failure.

Discussion Calling this method preloads buffers and acquires the audio hardware needed for playback, which minimizes the lag between calling the play method and the start of sound output.

Calling the stop method, or allowing a sound to finish playing, undoes this setup.

关于iphone - iPhone 中的 AVAudioPlayer prepareToPlay 回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8379669/

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