Search code examples
iphoneios4ios5audioqueue

iphone: how to buffer and play audio?


I need to implement the code for my app to buffer and play my audio file which is I am streaming.

I got one of the option AudioQueue but didn't find much code to understand the things to implement.

I have tried with Simply creating streamer and destroying streamer.

-(void)destroyStreamer
{
    if(streamer)
        [streamer stop];
}

-(void)createStreamer
{
    if(streamer)
        return;
    [self destroyStreamer];

    NSString *escapedValue = (__bridge_transfer NSString * )CFURLCreateStringByAddingPercentEscapes(nil, (__bridge CFStringRef)txtField.text, NULL, NULL, kCFStringEncodingUTF8);

    NSURL *url = [NSURL URLWithString:escapedValue];

    streamer = [[AudioStreamer alloc] initWithURL:url];


}

Solution

  • You may need to use the AudioToolBox framework.

    There are multiple ways of playing sounds (long/short/format support etc...). checkout this presentation which covers it from start to end.