我使用objectAL来传输PCM数据,
来自我尝试过的示例代码或播放在线CGI流数据
ALSource *source = [[ALSource source] retain];
ALBuffer *buffer = [[[OpenALManager sharedInstance] bufferFromUrl:[NSURL URLWithString:[[OpenALManager sharedInstance]bufferAsyncFromUrl:[NSURL URLWithString:@"someURL/somedata.cgi"] target:self selector:@selector(recievedBufferData:)]]] retain];
source.position = alpoint(planet.position.x, planet.position.y, 0);
source.referenceDistance = 50;
[OpenALManager sharedInstance].currentContext.listener.position = alpoint(rocketShip.position.x, rocketShip.position.y, 0);
self.isTouchEnabled = YES;
[source play:buffer loop:YES];
}
-(void)recievedBufferData:(id)recievedData{
NSLog(@"recieved");
}
我收到以下错误
OAL错误: - [OALAudioFile initWithUrl:reduceToMono:]
:无法打开url某个url / somefile.cgi(错误代码0xffffffd5:未知的ext音频错误)
但是方法recievedBufferData:只被调用一次
我无法播放.cgi文件,任何人都可以建议我如何在iphone中播放.cgi文件。
答案 0 :(得分:0)
我正在尝试类似的东西,但无法解决它。
我想问一下,我认为以下代码行中有一些错误?:
ALBuffer *buffer = [[[OpenALManager sharedInstance] bufferFromUrl:[NSURL URLWithString:[[OpenALManager sharedInstance]bufferAsyncFromUrl:[NSURL URLWithString:@"someURL/somedata.cgi"] target:self selector:@selector(recievedBufferData:)]]] retain];
为什么要调用bufferFromUrl和bufferAsyncFromUrl?
BTW我可以使用本地文件来完成这项工作:
buffer = [[[OpenALManager sharedInstance] bufferFromFile:@“ColdFunk.caf”] retain]; ng