views:

333

answers:

2

Hi I am writing an application to contact a webserver running on a desktop to access and play mp3 files. Here is what I tried so far: I have used MPMusicPlayerController (and tried UIWebview) to handle the audio file and it automatically plays after progressively downloading the file. There is no way to handle skipping songs and playing after progressive download of a file is not a good solution for cellular network.

Ideally, I would like to have the following function 1. Client requests a stream to be created using a specific bitrate (to handle different network condition) 2. Client should be able to skip songs

Can anyone point me in the right direction? Can m3u8 files support these functions?

Thanks for any help in advance.

+1  A: 

Take a look at AVPlayer, it can stream MP3's over the network connection.

        AVPlayer *player = [[AVPlayer playerWithURL:[NSURL URLWithString:@"http://www.mp3.com/mp3file.mp3"]] retain];

    [player play];

Check the documentation.

rule
+1  A: 

I ended up using 1. MPMediaPlayback protocol for controlling the MPMoviePlayerController 2. MPMoviePlayerPlaybackDidFinishNotification to determine if the playback completed due to error or due to user input.

The player plays fine both with streaming and Progressive download. The sample MoviePlayer code at http://developer.apple.com/iphone/library/samplecode/MoviePlayer_iPhone/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007798 is an excellent starting point.

rydgaze