How to play even background mode using MPMoviePlayerController

穿精又带淫゛_ 提交于 2019-12-24 16:12:41

问题


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.


回答1:


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

}


来源:https://stackoverflow.com/questions/9292421/how-to-play-even-background-mode-using-mpmovieplayercontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!