2013-05-02 5 views
0

MPMoviePlayerViewController를 사용하여 스트리밍 오디오를 재생하는 iphone 앱을 개발 중입니다. 다음 코드를 사용하면 정상적으로 작동합니다.전화 통화 종료 후 MPMoviePlayerViewController 다시 시작

moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL]; 
[moviePlayerController.view setFrame:CGRectMake(0, 83, 1024, 400)]; 
    moviePlayerController.moviePlayer.controlStyle = MPMovieControlModeVolumeOnly; 
[moviePlayerController.moviePlayer prepareToPlay]; 
    moviePlayerController.moviePlayer.shouldAutoplay=YES; 
    [moviePlayerController.moviePlayer play]; 

하지만 재생중인 플레이어가 통화 중에 멈 추면 중지됩니다. 전화 받기 후에 플레이어 스트리밍 노래를 다시 시작하겠습니다. 어떻게해야합니까?

Plaese 어떤 제안이라도 감사하겠습니다.

답변

1

NSNotificationCenter을 사용하여 알림을 등록하십시오. 따라서 앱이 포 그라운드로 오면 재생을 다시 시작할 수 있습니다. 모든 iOS 앱에서 이러한 이벤트를 처리하는 올바른 방법입니다. 자세한 내용은

NSNotificationCenter Class Reference on apple docs

에 또한 refer this이 따라야 할 정확한 단계를 알 수 있습니다 참조하십시오.

0

당신은 당신의 응용 프로그램 위임 클래스에서 구현 주어진 방법을 사용할 수있다

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

// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 
} 
+0

예. 전에 시도한 다음 스택에 질문을 게시했습니다. –

+0

중단 된 후 플레이어를 호출하는 코드를 공유 할 수 있습니까? –

-1

... 당신의 상황에 따라

-(void)audioPlayerBeginInterruption:(AVAudioPlayer *)audioPlayer; 
{ 
    [self.audioPlayer pause]; 
} 

-(void)audioPlayerEndInterruption:(AVAudioPlayer *)audioPlayer; 
{ 
    [self.audioPlayer play]; 
} 

및 추가 도움 http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/AudioSessionProgrammingGuide/HandlingAudioInterruptions/HandlingAudioInterruptions.html ..

이러한 방법을 시도
+0

죄송합니다. 작동하지 않습니다. –

관련 문제