libsaria: Change volume function
I introduced a function for directly setting the new volume level. It does not allow changing by some value.
This commit is contained in:
parent
cfc86bd891
commit
f354a305ae
|
@ -21,8 +21,10 @@ class Audio
|
|||
Audio();
|
||||
~Audio();
|
||||
|
||||
/* Other functions */
|
||||
void init(int, char **);
|
||||
void load(string);
|
||||
void set_volume(double);
|
||||
|
||||
/* Control functions */
|
||||
bool play();
|
||||
|
|
|
@ -15,7 +15,9 @@ class Libsaria
|
|||
Libsaria(int, char**);
|
||||
~Libsaria();
|
||||
|
||||
/* Other functions */
|
||||
void load(string);
|
||||
void set_volume(double);
|
||||
void register_callback(callback_t, void (*)());
|
||||
|
||||
/* Control functions */
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
#include <libsaria/audio.h>
|
||||
|
||||
void Audio::set_volume(double volume)
|
||||
{
|
||||
GValue value = { 0, };
|
||||
g_value_init(&value, G_TYPE_DOUBLE);
|
||||
g_value_set_double(&value, volume);
|
||||
g_object_set_property(G_OBJECT(player), "volume", &value);
|
||||
}
|
|
@ -15,3 +15,8 @@ void Libsaria::load(string filepath)
|
|||
audio.load(filepath);
|
||||
play();
|
||||
}
|
||||
|
||||
void Libsaria::set_volume(double volume)
|
||||
{
|
||||
audio.set_volume(volume);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue