Now we can use asynchronous initialization nodes to avoid the program hang during a long audio decoding process.
To convert our project from sync to asynchronous initialization we need to start moving all the code that need to be after the initialization to the event that will be triggered when the initialization of the player ends.
The delegated event returns a boolean with the initialization result equals to the synchronous initialization node.
The Bind of the event must be called before the Async Player Initialization node
With this modification we can avoid the game freeze moment when a big audio file is decoded, and continue doing more thing during the player initialization or add a loading screen.
Adding a decoding widget
We can add a widget, like a loading screen, to know when the audio decoding is running.
We can Add to Viewport the widget just after the Async Init Player Audio call. This will fill the screen with the decoding widget until the initialization process ends.
To remove the widget from the screen we need to Remove from parent our widget on the delegate event of OnInitPlayerAudioFinished event.
Support this blog!
For the past year I've been dedicating more of my time to the creation of tutorials, mainly about game development. If you think these posts have either helped or inspired you, please consider supporting this blog. Thank you so much for your contribution!