views:

68

answers:

1

I need to play some audio streaming contents on iPhone, but there are some options and problems I can't solve:

1. http://cocoawithlove.com/2009/06/revisiting-old-post-streaming-and.html

It is a library provided by Matt Gallagher, but I saw the Limited scope, and I would play a single song, not a radio station.

2. Suggestion from zonble

NSURL *URL = [NSURL URLWithString:@"http://zonble.net/MIDI/orz.mp3"];
NSData *data = [NSData dataWithContentsOfURL:URL];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithData:data error:nil];

But I need streaming for each "single song".

3. Using MPMoviePlayerController to wrapper.

Since the Class update new method, and

@interface MyAudioStreamer : UIViewController {
    MPMoviePlayerController *mp ;
}

instead of [self addSubview:mp.view] I use my own xib file to implement play and stop methods, but in this case, I have no idea to implement seekForward or seekBackward.

Is there any good idea to do AudioStreamer?

==== Update ====

after google 'AVPlayer' ,i used 3. Using MPMoviePlayerController to wrapper. to implement a auidoStreamer-like player ,there is something to share :

1.'playbackDidFinished' state there're 2 conditions : a song did finished and play next song or a song interrupt by user press stop or exception, i used enum to filter my state.

2 multi-task playing your song in background reference from https:// devforums.apple.com/message/264397

and if iOS SDK update, the solution might be changed because method would be diplicated. so i suggest to read library provided by Matt Gallagher.

anyone who konws when the library have no codec match download item (for example, my item encode by .AAC 128-bit and the library not support or at most .AAC 64-bit), what happen would the player be ?

A: 

You can either parse the icy meta data yourself, or if you're using iOS 4.0 you can playback using an AVPlayer and observe the timed metadata to discover the song boundaries and titles.

Rhythmic Fistman