Slider and volume control?

I posted a few years ago in the Code exchange regarding the welcomed “slider component” (based on the Button component in ui.lua). I try without success to control with a slider the sound volume, but have difficulty with CoronaLuaSyntax.
In ObjectiveC, I write, for the method:
-(IBAction) updateVolume {
[mediaPlayer setVolume:slider.value]
}

What’s the equivalent in CoronaLua to catch the value of the slider in a function?


require “slider”

local eventHandler = function (event)
media.setSoundVolume() --??? doesn’t work
end

local mySlider = slider.newSlider(
{
track = “track.png”,
thumbDefault = “thumb.png”,
thumbOver = “thumbDrag.png”,
onEvent = eventHandler,
}
)
-------end-------------

Thanks in advance for your help.

[import]uid: 8970 topic_id: 2801 reply_id: 302801[/import]

For those that are interested:

media.setSoundVolume(event.value/100)

–/100 to be in line with the min and max value defined in slider.lua (0-100)
–min and max value of mediaPlayer is between 0 -1

I tried also to settle in the table of the slider for example “value=20” (instead of 50), but seems to be nothing on the position of the thumb.png.

Any idea why? (I feel a little bit alone on this forum…:)). Thanks
[import]uid: 8970 topic_id: 2801 reply_id: 8496[/import]

I looked at the code for that slider. Looks like there needs to be an “update” function on it that you can call, once you change its value. There isn’t one there, but within the “newSlider” function you could add:

function slider:update()  
 -- do stuff here with "self.value", or "slider.value"  
end  

In your screen:

mySlider.value = .5  
mySlider:update()  

This slider component should have been made to accommodate for that. I don’t see much value in it as it is… [import]uid: 4454 topic_id: 2801 reply_id: 8593[/import]