如何使用 MPMoviePlayerController 播放背景模式

发布于 2025-01-05 23:31:30 字数 554 浏览 6 评论 0原文

使用IIS7的音频直播服务已准备就绪。 Audio Live流媒体服务器设置很复杂,但是已经成功了。

我获得了这样的流媒体URL(@“http://xxx.xxx.xx.xx/liveStream.isml/manifest(format=m3u8-aapl).m3u8”)。

我的使用代码出乎意料地简单。

   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];

嗯...我无法按照自己的意愿控制音乐播放器。

问题是这样的。

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

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

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

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.

Question is like this.

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

Please tell me some advice. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流星番茄 2025-01-12 23:31:30

请仅签入设备。我也在我的应用程序中完成了。我的代码如下所示。我正在谈论 iOS5

在 plist 中,我创建了一个名为“所需背景模式”的数组,并在数组名称中插入一个项目“应用程序播放音频”。有时会出现网址问题,请检查此网址MPMoviePlayer 声音工作在模拟器和 ipad 设备,但无法在 iPhone 设备中工作

  - (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];

}

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

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];

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文