2013-01-02 3 views
0

아이폰 라이브 라디오 응용 프로그램을 만들고 있습니다. 내 응용 프로그램이 백그라운드 모드에서 잘 작동합니다. 그러나 라디오 앱이 백그라운드 모드에서 재생 중일 때 전화 벨이 울리면 내 라디오가 중지됩니다.통화 후 라디오 중지

MP AVAudioSessionDelegateMediaPlayerOnly end interruption. Interruptor <Phone> category <completed> resumable <0>, _state = 6 
2013-01-02 10:26:24.487 Radio99[2527:707] MP endInterruptionFromInterruptor :: resuming playback at 1.000000 
+0

[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; 이 줄을 추가하면 아이폰 4에서 작동하지만 여전히 아이폰 5에서는 작동하지 않습니다. –

답변

0

AudioStreamer 만 사용하십시오. (전화 후에는 AVAudioPlayer 또는 MPMoviePlayerController을 사용하지 마십시오.)

NSURL *url =[NSURL URLWithString:@"http://y1.eoews.com/assets/ringtones/2012/5/18/34049/oiuxsvnbtxks7a0tg6xpdo66exdhi8h0bplp7twp.mp3"]; 
AudioStreamer *tempStreamer = [[AudioStreamer alloc] initWithURL:url]; 
self.streamer = tempStreamer; 
[tempStreamer release]; [streamer start]; 

배경이 코드 추가

- (void)applicationDidEnterBackground:(UIApplication *)application 
    { 

    CTCallCenter *_center = [[CTCallCenter alloc] init]; 

    _center.callEventHandler = ^(CTCall *call) 
     { 

     if ([call.callState isEqualToString:CTCallStateIncoming]) 
      { 
       NSLog(@"Pause"); 
       [streamPlayer pause]; 
      } 

     if ([call.callState isEqualToString:CTCallStateDisconnected]) 
      { 
      NSLog(@"call:%@", call.callState); 
      NSLog(@"Play"); 
      [streamPlayer start]; 
      } 
     }; 
    } 
} 
+0

[[AVAudioSession sharedInstance] setCategory : AVAudioSessionCategoryPlayback error : nil]; [[AVAudioSession sharedInstance] setActive : 예 오류 : nil]; [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; 위의 라인을 추가하고 라디오 작업을 완벽하게 !! –