samedi 7 février 2015

iOS Streaming MP3 File

I am a relatively new developer to iOS and I am writing an application that deals with streaming audio from an mp3 file on a website.


I want to play the audio as I stream it and I want the user to be able to scrub through the audio.


I have seen other posts use



NSData *songData=[NSData dataWithContentsOfURL:url];
[[AVAudioPlayer alloc] initWithData:songData error:nil];


But dataWithContentsOfURL: is synchronous and will block the main thread and is not streaming, and not what I am looking for.


Ideally I am looking for some way that I can access the bytes of data as I receive them, store them in a buffer, and then play that possibly incomplete buffer at some point (not necessarily immediately) while I get the rest of the data


I am not sure If there is a way to do this with AVPlayer, or if I need to look into Core Audio etc.


Can someone please send me in the right direction?


Aucun commentaire:

Enregistrer un commentaire