Control volume within lens
I am trying to give users the ability to adjust the volume within the lens. I have noticed some lenses will take a picture or record when volume buttons are pressed on the device while others control the volume of the device.
Is there a setting or script that reliably sets what behavior the external buttons have?
Here is a portion of a script that handles playing audio when a marker is detected but the audio.volume=100 line has no effect.
// Wait for 2 seconds before starting Audio
delayedAudioEvent = script.createEvent("DelayedCallbackEvent");
delayedAudioEvent.enabled=true;
delayedAudioEvent.bind(function(eventData)
{
print("Playing Audio....")
if(script.audio){
print("audio:"+ script.audio)
script.audio.volume= 100;
script.audio.play( -1 );
}
});
Hey there Paul,
You have the right idea, the only thing you need to change is the volume number. Instead of the number being between 1-100, it is between 0 and 1. So if you wanted your volume at half of its normal amount, you'd set it to 0.5. From what I can tell, you can't increase the volume more than 1, which is its default volume.
Hope that helps!
Ben
Hi Ben,
I had initially started with the 0-1 range but did not notice an effect so I was just testing out 0-100 since the documentation did not specify a range.
After further investigation of existing lenses, my biggest question is how game style lenses allow for volume control using external buttons vs other lenses take a recording when volume buttons are pressed.
I'd also like to know if it's possible to give iOS users the ability to control the volume with their phone's external buttons (instead of taking a picture) - like you can with some of Snapchat's game lenses. If not, this would be a nice option to add.