using AVAudioplayerNode play at particular NSTimeInterval time

208 views Asked by At

How to manage audio based UISlider using AVAudioPlayerNode.I am able to show playing time using NSTimer But I am unable to forward and rewind using 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);

    }

}

Can someBody tell me with code

0

There are 0 answers