Set UISlider.value to AVPlayer.currentTime

I am trying to set the value of UISlider to the current AVPlayer.

I am trying to use this code audioPlayer.currentTime = nowPlayingSlider.value;

I get this error:
Setter method is needed to assign to object using property assignment syntax How can I make this work.

+7
source share
3 answers

Here is how I dealt with this:

 -(IBAction) timeScrubberChange:(id) sender{ CMTime t = CMTimeMake(self.nowPlayingTimeScrubber.value, 1); self.nowPlayingCurrentTime.text = [self formatTimeCodeAsString: t.value]; self.nowPlayingDuration.text = [self formatTimeCodeAsString:(self.actualDuration - t.value)]; [self.avPlayer seekToTime:t]; } 
+9
source

Sam, check out two methods:

-currentTime and -seekToTime:

Here

They are in the AVPlayer class

+3
source

Maybe you have it the other way around?

To set the slider to the current location in the sound, it must be:

 [nowPlayingSlider setValue:[audioPlayer currentTime]]; 

To skip audio according to the slider change:

 [audioPlayer setCurrentTime:nowPlayingSlider.value]; 

Let me know if it works.

+1
source

All Articles