- Home /
Updating slider.value causes major stutter in VideoPlayer
I'm attempting to make a video player in Unity with the new VideoPlayer gameObject. I have made a slider to scrub through the time of the video which works perfectly fine, except there is one issue. I am trying to update the value of the slider every frame to scroll automatically as the video plays (like every video player has)
I have the following code:
public Slider timelineSlider;
void Update() {
timelineSlider.value = (float)player.frame;
}
With the code above in place, when I run the player and play a video clip, the framerate drops majorly and causes a huge amount of stutter in the video.
I tried only updating every 30 frames with:
public Slider timelineSlider;
void Update() {
if (Time.frameCount % 30 == 0) {
timelineSlider.value = (float)player.frame;
}
}
And you can still notice little stutters every 30 frames of the video (when it updates the slider). I don't understand why updating a slider can cause this. This very well may just be a bug report, but hopefully there's an alternative method for what I'm doing (or a simple fix)
Your answer
Follow this Question
Related Questions
Stuttering / performance issue with certain JS scripts 0 Answers
What could cause a periodic "freeze" with no memory or cpu spike? 0 Answers
2D Stutter/Flickering when moving at high speeds 0 Answers
Physics stutter in windows build 0 Answers
Application.targetFrameRate slows down FixedUpdate and physics simulation! 3 Answers