3

如何使用 AVAudioPlayerNode 管理基于音频的 UISlider。我能够使用 NSTimer 显示播放时间但我无法使用 UISlider 快进和快退

 _viewPlayerDuration.duration = duration;
 _viewPlayerDuration.currentTime = rTimer;
                [playerTimer invalidate];

                playerTimer=[NSTimer scheduledTimerWithTimeInterval: 0.1 target: self selector: @selector(updatePlayProgress:) userInfo: nil repeats: YES];
                [[NSRunLoop mainRunLoop] addTimer:playerTimer forMode:NSDefaultRunLoopMode];
(void)updatePlayProgress:(NSTimer *)ptimer
{
    if (duration < rTimer||duration == rTimer)
    {
        [audioPlayerNode stop];

        _playBGView.alpha=1.0;
        _doneBGView.alpha=1.0;
        [_playImage setImage:[UIImage imageNamed:@"play"]];

        playButton.userInteractionEnabled=YES;
        _doneButton.userInteractionEnabled=YES;
        [playerTimer invalidate];
        playerTimer=nil;

        _viewPlayerDuration.hidden=YES;
         recoringTimeLabel.text=@"00:00s";
    }

    else
    {
        rTimer=rTimer+ptimer.timeInterval;
        recoringTimeLabel.text=[self recordingTimeconversionFromSeconds:rTimer];

         [_viewPlayerDuration setCurrentTime:rTimer animated:YES];

        NSLog(@"%f",rTimer);

    }

}

someBody 可以用代码告诉我吗

4

0 回答 0