AVAudioPlayer - 为什么会出现环路之间(uncom pressed音频)的间隙 [英] AVAudioPlayer - Why is there a gap between loops (uncompressed audio)
问题描述
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];
这是基本的code我有,让我知道,如果你需要了解更多。
This is the basic code I've got, let me know if you need to know more.
试用过COM pressed和uncom pressed两种格式有关于〜1秒的差距在iPhone模拟器上运行时(没有开发许可证的设备上运行测试)。
tried both compressed and uncompressed formats both have a gap of about ~1 second when running on iPhone simulator (don't have dev license to run on device to test).
我缺少的东西,我一直在寻找的职位,但我只能看到与COM pressed音频问题(这是有道理的)。
Am i missing something, I've been searching posts but i can only see issues with compressed audio (which makes sense).
X code: 6.2版(6C131e)
操作系统:的OS X版本的优胜美地10.10.2(14C1510)
硬件:的Macbook Air 13(2014年年初) - 4GB
Xcode: Version 6.2 (6C131e)
OS: OS X Yosemite Version 10.10.2 (14C1510)
Hardware: Macbook Air 13" (Early 2014) - 4GB
推荐答案
你喜欢玩这之前尝试prepareToPlay
have you try a "prepareToPlay" before playing like this :
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];
这篇关于AVAudioPlayer - 为什么会出现环路之间(uncom pressed音频)的间隙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!