mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 23:14:46 +00:00
playback/player: gtk-play: use volume-changed signal from player to update the volume slider.
This commit is contained in:
parent
80eefca0d1
commit
2a2c10ac25
1 changed files with 22 additions and 0 deletions
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/tag/tag.h>
|
#include <gst/tag/tag.h>
|
||||||
|
@ -1530,6 +1531,25 @@ media_info_updated_cb (GstPlayer * player, GstPlayerMediaInfo * media_info,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
player_volume_changed_cb (GstPlayer * player, GtkPlay * play)
|
||||||
|
{
|
||||||
|
gdouble new_val, cur_val;
|
||||||
|
|
||||||
|
cur_val = gtk_scale_button_get_value
|
||||||
|
(GTK_SCALE_BUTTON (play->volume_button));
|
||||||
|
new_val = gst_player_get_volume (play->player);
|
||||||
|
|
||||||
|
if (fabs (cur_val - new_val) > 0.001) {
|
||||||
|
g_signal_handlers_block_by_func (play->volume_button,
|
||||||
|
volume_changed_cb, play);
|
||||||
|
gtk_scale_button_set_value (GTK_SCALE_BUTTON (play->volume_button),
|
||||||
|
new_val);
|
||||||
|
g_signal_handlers_unblock_by_func (play->volume_button,
|
||||||
|
volume_changed_cb, play);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (gint argc, gchar ** argv)
|
main (gint argc, gchar ** argv)
|
||||||
{
|
{
|
||||||
|
@ -1612,6 +1632,8 @@ main (gint argc, gchar ** argv)
|
||||||
g_signal_connect (play.player, "end-of-stream", G_CALLBACK (eos_cb), &play);
|
g_signal_connect (play.player, "end-of-stream", G_CALLBACK (eos_cb), &play);
|
||||||
g_signal_connect (play.player, "media-info-updated",
|
g_signal_connect (play.player, "media-info-updated",
|
||||||
G_CALLBACK (media_info_updated_cb), &play);
|
G_CALLBACK (media_info_updated_cb), &play);
|
||||||
|
g_signal_connect (play.player, "volume-changed",
|
||||||
|
G_CALLBACK (player_volume_changed_cb), &play);
|
||||||
|
|
||||||
play.playing = TRUE;
|
play.playing = TRUE;
|
||||||
play_current_uri (&play, g_list_first (play.uris), NULL);
|
play_current_uri (&play, g_list_first (play.uris), NULL);
|
||||||
|
|
Loading…
Reference in a new issue