Hi
I use the audio loader from the examples
sometime it works - sometimes not.
The program loads a very big texture (30 MB +) and an audio file 3 MB plus then waits for a click to start.
Sometimes the music is ready and scene and music start together - sometimes music does not start - but after stopping and click again it starts but is not synced with the scene anymore.
I looked through tons of examples - I did not find any where someone uses some sort of code which checks if the sound file is ready.
Is there a way to check that and enable the start click only if the sound will start together with the turning of the mesh?
Have you considered to use an instance of THREE.LoadingManager
and pass it to the texture and audio loader? You can then register an onLoad()
callback to the manager which only fires when all loaders have finished their loading process.
You can only allow interaction (meaning the start click) when the callback has been executed.
else if (PAP == "MUSICLOAD")
{
Action = "MUSICLOAD";
if(TL_soundfile == '')
{
TL_listener = new THREE.AudioListener();
cameraPano.add(TL_listener);
TL_soundfile = "../Music/" + rowArray[Posi+1];
TL_sound = new THREE.Audio( TL_listener);
TL_audioLoader = new THREE.AudioLoader();
TL_audioLoader.load(TL_soundfile, function(buffer)
{
TL_sound.setBuffer(buffer);
TL_soundLooping=true;
TL_sound.setLoop(TL_soundLooping);
TL_sound.setVolume(1.0);
});
}
That’s what I am using
I have just looked for the LoadingManager in the docs.- have not used it before.
But seems to be a solution.
Thank you
I will try to add that somehow that it fits to my code
Hmm
the audioLoader.load delivers a callback as I just read while looking closer into the docs and I shall add the onProgress function which gives the progress in percent.
I will try that first
Yes - that did it - calling the onProgress variable and prevent the click until its 100% made it
So I thought - That’s what solves my problem getting the progress of the texture loader as well
// onProgress callback currently not supported
undefined,
What did the Rolling Stones knew long ago? You can’t always get what you want …
TBH, it’s uncommon to use onProgress()
this way. Use onLoad()
if you want to execute logic when the loading process has been finished.