简体   繁体   English

iOS 4背景HTTP Live Stream

[英]iOS 4 background HTTP Live Stream

I'd like to play an audio HTTP Live Stream in background. 我想在后台播放音频HTTP Live Stream。 But how do I do that? 但是我该怎么做呢?

I tried to add the key (an Array) "UIBackgroundModes" with value "audio" to the info.plist. 我试图将值为“ audio”的键(数组)“ UIBackgroundModes”添加到info.plist。 Now I try to play audio with the MPMoviePlayerController. 现在,我尝试使用MPMoviePlayerController播放音频。 But as soon as the app goes into background, the audio Playback stops! 但是,一旦应用进入后台,音频播放就会停止! I don't know of any other API to play a HTTP Live Stream on the iPhone. 我不知道要在iPhone上播放HTTP Live Stream的任何其他API。 So is there an other or am I doing something wrong? 那么,还有其他事情还是我做错了什么? I searched all over the apple documentation but couldn't find anything useful. 我在苹果文档中搜索了所有内容,但找不到有用的东西。 There isn't much about background audio in the docs :-( 在文档中关于背景音频的内容不多:-(

See http://developer.apple.com/iphone/library/qa/qa2010/qa1668.html for a description of what changed in iOS4 and how to implement the functionality you want. 请参阅http://developer.apple.com/iphone/library/qa/qa2010/qa1668.html ,以获取有关iOS4中所做的更改以及如何实现所需功能的描述。

This works for me in one of my apps. 这在我的一个应用程序中对我有效。

Found a soluton: setting useApplicationAudioSession to NO on the MPMoviePlayerController does the job. 发现soluton:设置useApplicationAudioSessionNO上的MPMoviePlayerController做这项工作。 But it works only on audio only streams. 但它仅适用于仅音频流。 Video streams still stop. 视频流仍然停止。

player.useApplicationAudioSession = NO;

将音频会话类别设置为kAudioSessionCategory_MediaPlayback可能有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM