使用AVAudioplayerNode在特定的NSTimeInterval时间播放

时间:2016-12-27 13:08:10

标签: objective-c nstimeinterval avaudioplayernode

如何使用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可以用代码告诉我

0 个答案:

没有答案