2011-09-17 5 views
5

私はそのためのコードの下に使用していますが、私は、スライダーをスライドするときには、updateTimeメソッドを呼び出しますがplayer.currentTimeで立ち往生し、間違っている可能性が何 iPhoneアプリケーションのAVAudioPlayerで機能しない機能をシークしますか?

On single sliding of slider it gets stuck

-(IBAction)slide 
{ 
    [player setCurrentTime:slider.value]; 
    //NSLog(@"slider value in slide : %f",[slider value]); 

} 

    -(void) updateTime:(NSTimer *)timer 
    { 
     slider.value = player.currentTime; 
     //NSLog(@"player current time in update time : %f",[player currentTime]); 
     } 

    - (IBAction)play:(id)sender { 

     NSError *error; 
     NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Sing_for_me.mp3" ofType:nil]]; 
     player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error]; 
     if(!player) NSLog(@"Error : %@",&error); 
     [player prepareToPlay]; 
     slider.continuous=YES; 

     slider.maximumValue = [player duration]; 
     //NSLog(@"player duration : %f",[player duration]); 
     // NSLog(@"slider duration : %f",slider.value); 
     //NSLog(@"player current time : %f",[player currentTime]); 
     slider.value=0.0; 

     [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTime:) userInfo:nil repeats:YES]; 
     [player play]; 
    } 

更をプレイしていませんか?

答えて

関連する問題