I would like to load a video asynchronously, so as not to block the message thread, but on Windows VideoComponent::loadAsync just calls VideoComponent::load. I assume I need to implement my own thread to load in the background.
a) I wanted to verify that I need write some ifdefed code for windows to use a thread, but can rely on loadAsync for OSX, iOS, and Android?
b) wouldn’t it make sense for JUCE VideoComponent::loadAsync to use it’s own thread, so that the function actually operates the same on all platforms?
ACK! ffs… VideoComponent::load calls resized() when it’s done… which of course, can’t be called in a thread… and, it means VideoComponent::load operates differently than VideoComponent::loadAsync, which does not call resized()… JUCE team, can you assist with this? either implement a proper loadAsync() for Windows, or allow us a method to call load() from a thread?
Yes, loadAsync() should work fine for iOS, macOS and Android. We probably won’t have time to look at implementing a proper loadAsync() on Windows in the near future, but would removing the call to resized() work for your use case for the time being?
That would totally work! I have already written the code to do the load on it’s own thread, and discovered the call to resized() when testing it the first time. Thanks.
Hmm, I’m not seeing any issues using loadAsync(). It could be that the VideoComponent wasn’t being resized correctly after that change, so I’ve pushed 404455b which will start the resize timer after loading if done asynchronously. Can you see if that fixes your issue? If not then could you post a simple example which reproduces the issue and I’ll look into it.
I am still having issues. I verified using load from the message thread is still working. I know you asked for a simple example, and I hope the class I’ve implemented is considered simple enough, otherwise let me know, and I will reduce it even more. As well, here is a video showing what I am experiencing. Loading Video from Thread
From looking at the implementation of the Windows VideoComponent, I don’t think it’s quite as easy as just calling the loadAsync() method on a thread. There’s a lot of code in the internal loading which needs to be called on the message thread for things like creating the native HWND which displays the video. Unfortunately I can’t see an easy way of pulling this out without basically rewriting most of the class, I can add this to the backlog but I’m afraid it’s not particularly high priority.