navseek: toggle pause/play on space bar

A useful thing to have.

https://bugzilla.gnome.org/show_bug.cgi?id=659065
This commit is contained in:
Vincent Penquerc'h 2011-09-14 16:37:12 +01:00 committed by Tim-Philipp Müller
parent 682ae32f6f
commit 352bab2ef7

View file

@ -211,6 +211,23 @@ gst_navseek_segseek (GstNavSeek * navseek)
gst_object_unref (peer_pad);
}
static void
gst_navseek_toggle_play_pause (GstNavSeek * navseek)
{
GstStateChangeReturn sret;
GstState current, pending, state;
sret = gst_element_get_state (GST_ELEMENT (navseek), &current, &pending, 0);
if (sret == GST_STATE_CHANGE_FAILURE)
return;
state = (pending != GST_STATE_VOID_PENDING) ? pending : current;
gst_element_post_message (GST_ELEMENT (navseek),
gst_message_new_request_state (GST_OBJECT (navseek),
(state == GST_STATE_PLAYING) ? GST_STATE_PAUSED : GST_STATE_PLAYING));
}
static gboolean
gst_navseek_handle_src_event (GstPad * pad, GstEvent * event)
{
@ -263,6 +280,8 @@ gst_navseek_handle_src_event (GstPad * pad, GstEvent * event)
} else if (strcmp (key, "n") == 0) {
/* normal speed */
gst_navseek_change_playback_rate (navseek, 1.0);
} else if (strcmp (key, "space") == 0) {
gst_navseek_toggle_play_pause (navseek);
}
} else {
break;