About the current volume

Hello,
I’m trying to force the volume to maximum then listen when the user put it to 0 :

local function listenVolume(evt)  
 local vol=audio.getVolume()  
 vol\_txt.text=tostring(vol)  
 if vol==0 then vol\_txt.isVisible=false end  
end  
  
audio.setVolume(1)   
timer.performWithDelay(500,listenVolume,0)  

Compiled for Android, the volume is not initialised to the maximum level and the text always shows 1… in fact nothing works, why!?

Thanks to show me the right way!
[import]uid: 107239 topic_id: 24617 reply_id: 324617[/import]

Can you provide plug and play code (except the sound file, obviously) and I’ll try to reproduce this? :slight_smile: [import]uid: 52491 topic_id: 24617 reply_id: 100048[/import]

What I need is very simple : get the current volume of the device.
The following code doesn’t work. By increasing or decreasing the volume on my mobile the displayed value should be between 0 and 1 but it’s always 1 :

local volume\_txt=display.newText("volume",100,100)  
  
local function listenVolume(evt)  
 volume\_txt.text=tostring(audio.getVolume())  
end  
  
timer.performWithDelay(250,listenVolume,0)  

Thanks for trying it :slight_smile:
[import]uid: 107239 topic_id: 24617 reply_id: 100126[/import]

I don’t think getVolume() returns the volume of the device. It is a software volume set by your app for all audio or specific channels, if you specify them. If you never set the volume, your app master volume is set at 1.0. Volume in Corona is between 0 and 1.0.

The device volume overrides any software volume settings. So if the device volume is off or set to 0, your app will not be heard regardless if internally it’s set to 1.0. Best explanation I guess would be the volume in your app is a percentage of your device volume.
[import]uid: 56820 topic_id: 24617 reply_id: 100157[/import]

Ok I understand, it’s the volume of the audio lib. The device’s volume should be returned by the system lib which doesn’t exist yet unfortunately. Thanks for the info ! [import]uid: 107239 topic_id: 24617 reply_id: 100237[/import]

OH I’m sorry, I totally misread this - you’re correct. You can post this in feature requests if it is important to you :slight_smile: [import]uid: 52491 topic_id: 24617 reply_id: 100260[/import]