gpt4 book ai didi

ios - AVAudioPlayer - 为什么循环之间有间隙(未压缩的音频)

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

NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"caf"];
audioPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[audioPlayer setNumberOfLoops:-1];
[audioPlayer setVolume: 0.1];
[audioPlayer play];

这是我得到的基本代码,如果您需要了解更多信息,请告诉我。

在 iPhone 模拟器上运行时,压缩和未压缩格式都尝试了大约 1 秒的差距(没有开发许可证在设备上运行以进行测试)。

我是不是遗漏了什么,我一直在搜索帖子,但我只能看到压缩音频的问题(这是有道理的)。


Xcode:版本 6.2 (6C131e)
操作系统: OS X Yosemite 版本 10.10.2 (14C1510)
硬件:Macbook Air 13"(2014 年初)- 4GB

最佳答案

你在这样玩之前试过“prepareToPlay”吗:

NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"caf"];
audioPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[audioPlayer setNumberOfLoops:-1];
[audioPlayer setVolume: 0.1];
[audioPlayer prepareToPlay];
[audioPlayer play];

关于ios - AVAudioPlayer - 为什么循环之间有间隙(未压缩的音频),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29011852/

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