寻求iPhone App中的AVAudioPlayer无效的功能?

时间:2011-09-17 03:28:44

标签: iphone objective-c ios ios4 avaudioplayer

我正在使用下面的代码,但当我滑动滑块时,它调用了updateTime方法,但卡在了player.currentTime而没有进一步播放

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];
    }

可能出错?

0 个答案:

没有答案