diff --git a/libraries/audio/src/ScriptAudioInjector.h b/libraries/audio/src/ScriptAudioInjector.h
index 3b160211168..165cbc318c3 100644
--- a/libraries/audio/src/ScriptAudioInjector.h
+++ b/libraries/audio/src/ScriptAudioInjector.h
@@ -65,9 +65,9 @@ public slots:
* Stops audio playback.
* @function AudioInjector.stop
* @example
Stop playing a sound before it finishes.
- * var sound = SoundCache.getSound(Script.resourcesPath() + "sounds/sample.wav");
- * var injector;
- * var injectorOptions = {
+ * const sound = SoundCache.getSound(Script.resourcesPath() + "sounds/sample.wav");
+ * let injector;
+ * const injectorOptions = {
* position: MyAvatar.position
* };
*
@@ -85,13 +85,50 @@ public slots:
* Gets the current configuration of the audio injector.
* @function AudioInjector.getOptions
* @returns {AudioInjector.AudioInjectorOptions} Configuration of how the injector plays the audio.
+ * @example Prints injector options to log
+ * let sound = SoundCache.getSound(Script.resourcesPath() + "sounds/sample.wav");
+ * let injector;
+ * let injectorOptions = {
+ * position: MyAvatar.position,
+ * volume: 0.8,
+ * };
+ *
+ * Script.setTimeout(function () { // Give the sound time to load.
+ * injector = Audio.playSound(sound, injectorOptions);
+ * }, 1000);
+ *
+ * Script.setTimeout(function () {
+ * const options = injector.getOptions();
+ *
+ * print("Current AudioInjectorOptions: ",JSON.stringify(options)); // Print all options to log
+ *
+ * print("Volume is set to ", options.volume);
+ * }, 2000);
*/
AudioInjectorOptions getOptions() const { return DependencyManager::get()->getOptions(_injector); }
/*@jsdoc
* Configures how the injector plays the audio.
+ * This will replace all current AudioInjectorOptions.
* @function AudioInjector.setOptions
* @param {AudioInjector.AudioInjectorOptions} options - Configuration of how the injector plays the audio.
+ * @example Reduce the volume of the sound without changing other existing options.
+ * const sound = SoundCache.getSound(Script.resourcesPath() + "sounds/sample.wav");
+ * let injector;
+ * const injectorOptions = {
+ * position: MyAvatar.position,
+ * volume: 1.0,
+ * };
+ *
+ * Script.setTimeout(function () { // Give the sound time to load.
+ * injector = Audio.playSound(sound, injectorOptions);
+ * }, 1000);
+ *
+ * Script.setTimeout(function () {
+ * const options = injector.getOptions();
+ * options.volume = 0.2 // Reduce volume
+ * injector.setOptions(options); // replace existing options
+ * }, 5000);
*/
void setOptions(const AudioInjectorOptions& options) { DependencyManager::get()->setOptions(_injector, options); }
@@ -107,9 +144,9 @@ public slots:
* @function AudioInjector.isPlaying
* @returns {boolean} true if the audio is currently playing, otherwise false.
* @example See if a sound is playing.
- * var sound = SoundCache.getSound(Script.resourcesPath() + "sounds/sample.wav");
- * var injector;
- * var injectorOptions = {
+ * const sound = SoundCache.getSound(Script.resourcesPath() + "sounds/sample.wav");
+ * let injector;
+ * const injectorOptions = {
* position: MyAvatar.position
* };
*
@@ -130,9 +167,9 @@ public slots:
* @function AudioInjector.finished
* @returns {Signal}
* @example Report when a sound has finished playing.
- * var sound = SoundCache.getSound(Script.resourcesPath() + "sounds/sample.wav");
- * var injector;
- * var injectorOptions = {
+ * const sound = SoundCache.getSound(Script.resourcesPath() + "sounds/sample.wav");
+ * let injector;
+ * const injectorOptions = {
* position: MyAvatar.position
* };
*