Function to change the specific music volume? #1200
Replies: 3 comments 3 replies
-
I think a better solution is to mark each music/sound a label(id/key), maybe it could be a return string(id/key) of audioPlayer.loopMusic or .playMusic method var id = FXGL.getAudioPlayer().loopMusic(bgm);
FXGL.getAudioPlayer().setVolume(id, 0.5); and it would be nice to have a method to return the original volumeProperty var volumeProperty = FXGL.getSettings().getMusicVolumeProperty(id);
//or
var volumeProperty = FXGL.getSettings().getMusicVolumeProperty(music); then we could use Timeline to create a volume property transition Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), new KeyValue(getSettings().getMusicVolumeProperty(id), 0)));
timeline.play(); |
Beta Was this translation helpful? Give feedback.
-
Thanks, I think this is covered in #1187 I'll mark it as a priority issue |
Beta Was this translation helpful? Give feedback.
-
Hi @AlmasB & @chengenzhao, I'm currently trying to integrate dynamic audio volumes for my game and since we don't have access to the volume property, I ended up doing this:
For now, this seems like an heavy workaround. It would be much easier to have access to the volume property. Also, I've looked at the code and having different sound volumes isn't possible as it will get reverted and replaced whenever a player do "Pause" because the unpause sequence resets volumes to master volumes. I'll probably make a PR to resolve this :) Can I? |
Beta Was this translation helpful? Give feedback.
-
Hi:
We tried to find a way to tune the specific music volume
but seems like current API doesn't support this function
and we read the source code
seems like music.getAudio().setVolume() works
but this is internal API
so is it possible to provide a wrap function that allow developer to tune the specific music volume
or simply make music.getAudio() function open?
We currently have two background music
one is normal background music, the other one is white noise like train running noise or raining noise etc.
so some times we need to adjust just background music and keep the white noise running
Thanks
Beta Was this translation helpful? Give feedback.
All reactions