2013-10-31 6 views
0

iOS SDK에서 재생 시간을 A 초에서 B 초까지 재생하고 싶습니다. 그러나, 나는 아직도 이것을 구현하는 방법을 찾지 못했습니다.지속 시간 입력으로 노래 재생

나를 도와주는 사람이 있습니까? 미리 감사드립니다.

답변

1

당신은 단순히 당신의 대답을

- (void) updateTime: (NSTimer*) time 
{ 

if (_audioPlayer.currentTime >= _endingTime) 
{ 
    //pause 
    [self playPauseButtonSelector:nil]; 
} 

} 
+0

감사 재생을 중지 할 종료 지점으로 audioPlayer의 currentTime을 비교, 기능 updateTime에서 AVAudioPlayer

- (void) playPauseButtonSelector: (UIButton*) sender { if (!_isPlaying) { //play song _timer = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(updateTime:) userInfo:nil repeats:YES]; [_audioPlayer setCurrentTime:_startingTime]; [_audioPlayer play]; _isPlaying = YES; } else { //pause action [_audioPlayer pause]; [_timer invalidate]; _timer = nil; _isPlaying = NO; } } 

를 사용할 수 있습니다. 이것은 내가 필요한 것입니다. –