Set UISlider.value to AVPlayer.currentTime

拜拜、爱过 提交于 2020-01-01 09:31:55

问题


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 this to work.


回答1:


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];                                
}



回答2:


Sam, check this two methods:

-currentTime and -seekToTime:

Here

They are in AVPlayer class




回答3:


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.



来源:https://stackoverflow.com/questions/7139927/set-uislider-value-to-avplayer-currenttime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!