2016-11-24 2 views
0

AVAudioplayer를 사용하는 Iam과 버튼을 누르면 몇 초 동안 음악을 일시 중지하고 6 초 후에 아무 버튼도 누르지 않고 음악을 다시 시작하고 싶습니다. 그게 가능한가? 그렇다면 어떻게 할 수 있습니까? 여기 내 코드의 샘플은 다음과 같습니다몇 초 동안 AVAudioplayer 일시 중지

나는 잘 모릅니다
NSString *soundPath2 =[[NSBundle mainBundle] pathForResource:@"background" ofType:@"wav"]; 

NSURL *soundURL2 = [NSURL fileURLWithPath:soundPath2]; 
NSError *error2 = nil; 
self.backgroundMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:soundURL2 error:&error2]; 

self.backgroundMusic.numberOfLoops = 9; 
[self.backgroundMusic prepareToPlay]; 
[self.backgroundMusic play]; 

답변

0

이있는 바로이 작업을 수행하는 방법,하지만 만약 내가 잘못이

[self.backgroundMusic pause]; 
[NSTimer scheduledTimerWithTimeInterval:6.0 
           target:self 
           selector:@selector(continuePlay) 
           userInfo:nil 
           repeats:NO]; 
       ......................... 

-(void)continuePlay{ 
[self.backgroundMusic play]; 
} 

저를 수정하시기 바랍니다했다!

관련 문제