如何使用MPMoviePlayerController播放背景模式 [英] How to play even background mode using MPMoviePlayerController

查看:90
本文介绍了如何使用MPMoviePlayerController播放背景模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用IIS7的音频实时流服务已准备就绪. 音频实时流服务器的设置非常复杂,但是成功了.

Audio Live Streaming Service using IIS7 is prepared. Audio Live streaming server setting is very complex, but have succeeded.

我获得了这样的流式传输URL(@"http://xxx.xxx.xx.xx/liveStream.isml/manifest(format = m3u8-aapl).m3u8").

I obtained a URL for streaming like this(@"http://xxx.xxx.xx.xx/liveStream.isml/manifest(format=m3u8-aapl).m3u8").

我的使用代码异常简单.

My using code is unexpectedly simple.

   self.theURL = [NSURL URLWithString:@"http://xxx.xxx.xx.xx/liveStream.isml/manifest(format=m3u8-aapl).m3u8"]; 

   if(moviePlayer == nil)
   {
       moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theURL];
   } 
    [moviePlayer play];

嗯...我无法控制音乐播放器.

Hm... I can't control music player as I wished.

问题就是这样.

即使背景模式,我也不想停止播放音乐.

I don't want to stop to play music even though backgroundMode.

请告诉我一些建议.谢谢.

Please tell me some advice. Thanks.

推荐答案

请仅检入设备.我也在我的应用程序中完成过操作.我的代码如下所示.我在谈论 iOS5

please check in only device.I have also done in my Application. My code is given below.i am talking about iOS5

然后在plist中,我创建了一个名为必需的后台模式"的数组,并在数组名称"App Plays Audio"中插入了一个项目.有时会出现 URL问题检查此URL MPMoviePlayer声音可以在模拟器和ipad设备上运行,但不能在iPhone设备上运行

And in plist i made an array named "Required background mode" and insert an item in array name, "App Plays Audio". some times URL problem is occurs check this URL MPMoviePlayer sound working in Simulators and ipad device, but not Working in iPhone Device

  - (void)viewDidLoad 
  {
    [super viewDidLoad];
    NSError *setCategoryErr = nil;
    NSError *activationErr  = nil;
    [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryErr];
    [[AVAudioSession sharedInstance] setActive: YES error: &activationErr];
     [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
     UIBackgroundTaskIdentifier newTaskId = UIBackgroundTaskInvalid;
     newTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:NULL];

}

这篇关于如何使用MPMoviePlayerController播放背景模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆