The iPhone media player is very easy to use, but it only works in landscape mode and it seems designed more for video than audio. If you wish to play an onboard MP3 or an MP3 file as it’s downloading (not really streaming, but progressive download) you have another option! Use the audio player embedded with Safari running in a UIWebView.
Here’s how to do it without having to create a special window for it. Instantiate an UIWebView object using a 1×1 pixel sized frame (here self.playerView is an instance variable on my controller and is NOT added as a subview)
UIWebView *webView = [[UIWebView alloc] initWithFrame: CGRectMake(0.0, 0.0, 1.0, 1.0)]; webView.delegate = self; self.playerView = webView; [webView release];
Then load your NSURLRequest.
NSURLRequest *request = [[NSURLRequest alloc] initWithURL: [NSURL URLWithString: myMP3URL] cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval: myTimeoutValue]; [self.playerView loadRequest: request]; [request release];
That’s it! When the request starts downloading the player with full controls will launch and your screen will look the the picture below.

Check out the web view delegate methods to learn more about controlling the behavior of the web view to suite your specific needs.
Recent Comments