Skip to content

Commit 3cd6b16

Browse files
committed
Add script api example for AudioInjector.getOptions
1 parent ad11bd3 commit 3cd6b16

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

libraries/audio/src/ScriptAudioInjector.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,25 @@ public slots:
8585
* Gets the current configuration of the audio injector.
8686
* @function AudioInjector.getOptions
8787
* @returns {AudioInjector.AudioInjectorOptions} Configuration of how the injector plays the audio.
88+
* @example <caption>Prints injector options to log</caption>
89+
* let sound = SoundCache.getSound(Script.resourcesPath() + "sounds/sample.wav");
90+
* let injector;
91+
* let injectorOptions = {
92+
* position: MyAvatar.position,
93+
* volume: 0.8,
94+
* };
95+
96+
* Script.setTimeout(function () { // Give the sound time to load.
97+
* injector = Audio.playSound(sound, injectorOptions);
98+
* }, 1000);
99+
*
100+
* Script.setTimeout(function () {
101+
* const options = injector.getOptions();
102+
*
103+
* print("Current AudioInjectorOptions: ",JSON.stringify(options)); // Print all options to log
104+
*
105+
* print("Volume is set to ", options.volume);
106+
* }, 2000);
88107
*/
89108
AudioInjectorOptions getOptions() const { return DependencyManager::get<AudioInjectorManager>()->getOptions(_injector); }
90109

0 commit comments

Comments
 (0)