开发者

Play audio file stream using HTTP Live Streaming on iOS client without losing UI to Quick Time

开发者 https://www.devze.com 2023-02-05 09:50 出处:网络
I have a HTTP Live streaming server setup that serves segmented mp3 audio content (the URL points to playlist.m3u8 index file). I need to build an iOS client application to consume this audio stream w

I have a HTTP Live streaming server setup that serves segmented mp3 audio content (the URL points to playlist.m3u8 index file). I need to build an iOS client application to consume this audio stream without using any standard Apple controls/UI. It should play the stream in the background and I want to use my own custom UI for providing the controls.

Since the content is purely audio, I don't want to use MPMoviePlayerController class as it takes over the UI. I have tried using AVAudioPlayer, although it is not meant for network streams, which unsurprisingly fails to playback with an error code "-43" : NSOSStatusErrorDomain.

I have also tried to create an UIWebView with 1 pixel height and width and pointing it to the playlist.m3u8 file on the server. This works but unfortunately I still lose UI since UIWebView simply delegates the task of playing back to QuickTime player which launches within my app with full screen for iOS 3.xx devices.

Basically, it seem to me that Apple has not provided any client APIs for consuming HTTP Live Streaming audio streams and developers are forced to relinquish the UI to QuickTime player which plays the stream with the QT logo usurping the scree开发者_StackOverflow中文版n. ughh...

I would love to know if anyone has suggestions to help me with the above. Otherwise, my plan B is to abandon HTTP Live Streaming and use the famous Matt Gallagher classic streaming implementation. However, I am a bit worried about Apples guidelines that are clearly suggesting that for Apps that are expected to send large amount of Audio or Video content over cellular networks (which my app is) are required to use HTTP Live streaming. Does this mean that my plan B implementation is prone to rejection by Apple? Any ways to circumvent this guideline?


http://developer.apple.com/library/ios/#documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/Reference/Reference.html

The docs say:

Playback occurs in a view owned by the movie player and takes place either fullscreen or inline.

In iOS 3.1 and earlier, this class implemented a full-screen movie player only.

A quick test using Apple's sample streams proves what you want to do is possible.

MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/gear4/prog_index.m3u8"]];
player.movieSourceType = MPMovieSourceTypeStreaming;
player.view.hidden = YES;
[self.view addSubview:player.view];
[player play];


I used the audio streamer by Matt Gallagher in one of my apps. It's an internet radio app pretty much like Pandora and LastFM. And yes it was accepted by Apple and has been in the App Store since then.

So in my opinion, your plan B is actually not that risky. :-)

0

精彩评论

暂无评论...
验证码 换一张
取 消