Loading For SampleMaps
-
Hey!
Kind of a broad question. I have this viewport browser in my plugin which loads a samplemap when it is selected in the viewport. The thing is, the sample maps take time to load and be playable, but the ui is completly open and people can possibily cause an unwanted issue whilst the loading is occuring. I also have this label which whenever a entry in the viewport is clicked, it finds what samplemap is being loaded into the sampler and the label prints the samplemaps name. all this is within the veiwport callback:
inline function onvptLayerSearch0Control(component, value) { local currentSelectedLayerName = vptLayerSearch0.get("items").split("\n")[value].split("-")[1].trim(); local currentSelectedLayerSampleMap = layerScreenObject["All"][currentSelectedLayerName]["samplemap"]; sampler0.asSampler().loadSampleMap(currentSelectedLayerSampleMap); lblCurrentLayerName0.set("text", sampler0.asSampler().getCurrentSampleMapId().replace(" Sample Map")); };
However since the samplemap is loading, the label is set to the previous samplemap that was selected before the loading. I know that I could implement a timer to wait a couple milliseconds, but is there a more precise way to know when something like samplemaps are being loaded. I'd like to also put a panel to grey out the ui whilst the samplemap is loading to stop ui functions, and it to dissapear when the samplemap is done loading. And putting a timer would come with varied succeses since each samplemap would take a certain amount of time to load.
Edit: probably an easier way to understand it is this: If you change samplemaps, on the top of hise, a loading bar appears whilst the samplemap is loading. I'd like to be able to show a panel when the bar appears and the panel to dissapear when the loading bar is complete and dissapears
Thanks!
-
Preload callback is what you want
-
@d-healey Hmm, interesting! So is the preload callback technically put into place once the loading bar in hise completes?
-
@Casmat The loading callback will trigger once when loading begins and once when it ends. In between you can block the UI by showing a panel.
I demonstrated the loading callback in a video on Patreon earlier this month.
-
@d-healey Ahh, i see! I tried finding it in the docs, but I can only find two functions on getting messages and progress on the preload. Where can I find more info on how to implement this or any example which utilizes this form of callback?
Edit: Nice, just saw your edit! Will take a look at it!