开发者

Set UISlider.value to AVPlayer.currentTime

I am trying to set a UISlider's Value to a AVPlayer's Current Time.

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

I am getting this error:

Setter method is needed to assign to object using property assignment syntax

How do I get t开发者_运维知识库his to work.


Here is how I handled 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];                                
}


Sam, check this two methods:

-currentTime and -seekToTime:

Here

They are in AVPlayer class


Maybe you have it the other way round?

To set the slider to the current place in the sound it should be:

[nowPlayingSlider setValue:[audioPlayer currentTime]];

To skip in the audio according to a change of the slider:

[audioPlayer setCurrentTime:nowPlayingSlider.value];

Let me know if it works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜