Solved Dynamic SoundEffect
-
Hi,
I have some SoundEffects defined, e.g. se1 and se2, and in a function, I'd like to dynamically call one according to conditions. So instead of doing:
if (something) {
se1.play();
} else
se2.play();
}I'd like to do:
var se = "se1";
se.play();Is that possible?
Many thanks
-
Hi
You can set the source.
http://doc.qt.io/qt-5/qml-qtmultimedia-soundeffect.html#source-propand re-use the SoundEffect
-
Thanks mrjj,
So I'd only need to define one SoundEffect then, and just use it for whatever audio file I needed?
Would this make any difference to performance? If I had a SoundEffect for each audio file, would they be preloaded, and would this technique prevent that? Or should I still have a SoundEffect for each audio file to enable preloading, and then just change the source on one of them?Thanks again
-
@qmlnoob
well i think it resolves the source when assigned so no , it would not be preloaded before first time used.
For later calls I assume the resource is cached so same speed there. -
@mrjj
Thanks again for all the info! -
@qmlnoob
Np.
Just as note:
https://qmlbook.github.io/