2014-11-03 2 views
0

3 시간 동안 이미 작업 중이므로 해결 방법을 찾을 수 없습니다. 제 3 자 라이브러리를 사용하고 있습니다. 저에게 소리를 재생하고, AVAudioPlayer playSound를 사용하고 있다고 추측합니다. 내 앱이 사운드를 재생하는지 알 수있는 방법이 있는지 알고 싶습니다.앱에서 오디오가 재생되고 있는지 확인하십시오.

타사 라이브러리에 액세스 할 수 없으며 해당 사운드를 재생하기위한 속성이 비공개입니다. AVAudioSession을 시도해 보았지만 사운드 재생 여부를 확인하는 데는 두 가지 방법 밖에 없었습니다. 불행히도 앱 외부에서 나오는 소리 만 확인할 수 있습니다.

감사

+0

는이에 대한 모든 솔루션을 찾으셨습니까 이 링크를 참조? –

답변

-1
//Register self for remote notifications of play/pause toggle  
//(i.e. when user backgrounds app, double-taps home, 
    //then swipes right to reveal multimedia control buttons). 
    //See MyWindow.h for more info.  

Add this Notification Center where to detect playback 

[[NSNotificationCenter defaultCenter] addObserver:self            selector:@selector(toggling_Playback)             name:@"TogglePlayPause" object:nil]; 

- (void)toggling_Playback {  
    (self.player.isPlaying ? [self.player pause] : [self.player play]); 
} 


AVAudioPlayerDelegate protocol methods: 

- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)p successfully:(BOOL)flag { 
    [self.player stop];   
    [self ffButtonWasPressed]; 
    } 

- (void)audioPlayerBeginInterruption:(AVAudioPlayer *)player {  
//In real app, may persist this to NSUserDefaults to act on after interruption ends 
    //or app resumes.  
NSLog(@"Interruption began"); 

} 

//Note: this form is only for iOS >= 4.0. See docs for pre-4.0. 

- (void)audioPlayerEndInterruption:(AVAudioPlayer *)player withFlags:(NSUInteger)flags { 
    NSLog(@"Interruption ended"); 
    //restart playback if flag indicates we should resume 
    if (flags & AVAudioSessionInterruptionFlags_ShouldResume)  {  
    [self toggling_Playback];  
} 
} 

여전히 의심의 여지가 있다면 : 친절 http://www.allappsdevelopers.com/TopicDetail.aspx?TopicID=99cb8bf0-91ac-4c41-a903-2dc744444b7a