I’m trying create my own controller for QuicktimeMovieComponent, and I’m running into trouble with the horizontal slider that marks the movie’s current time. My original design idea was to create a separate thread that checked the movie’s current position every 100 ms, and then updated the horizontal slider. But since I’m calling a UI component from a thread other than the Message thread, I have to use a MessageManagerLock every time I update the time slider, and since it’s getting called every 100 ms, it’s creating a serious delay whenever I press any of the other buttons or sliders.
Any suggestions on how to make this work? Is there another approach I’m completely missing?
Use AsyncUpdater and in your handleAsyncUpdate() perform the modification to the UI component.
If you were using VFLib, slider was of type juce::Slider*, and newValue was a double with the new position, this code snippet could be called from your other thread with no issues (or locking):
MessageThread::getInstance().call (&Slider::setValue, slider, newValue, true, false);
That worked perfectly. Thanks TheVinn!
I take it back. While TheVinn’s solution (AsyncUpdater) did allow the slider to update, it briefly pauses the video when it does so. So there’s a hiccup in the video/audio every second. Obviously this is because both the slider update AND the Quicktime playback is being handled by the main message thread.
It seems in this case I HAVE to update this slider with a background thread, since the QuickTime playback can only be done with the main message thread. Looking around on this forum, I know that’s a big no-no. But the only solution I can think of is to comment out the assertion in JUCE that prevents me from doing so. I’d prefer not to do this of course. Is there another way around this?
It’s not obvious that this is the cause for the hiccup.
Doh. Your reply made me entertain the possibility that my newbie coding genius could in some way be fallible. And it was. :oops:
When I updated the slider I forgot to do it WITHOUT sending an updateMessage. Now we’re hiccup free. Thanks again!