From 352bab2ef74ce44a6b7f8b583ed549833e2315c2 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Wed, 14 Sep 2011 16:37:12 +0100 Subject: [PATCH] navseek: toggle pause/play on space bar A useful thing to have. https://bugzilla.gnome.org/show_bug.cgi?id=659065 --- gst/debugutils/gstnavseek.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gst/debugutils/gstnavseek.c b/gst/debugutils/gstnavseek.c index c7b674dbdc..5dedf604e5 100644 --- a/gst/debugutils/gstnavseek.c +++ b/gst/debugutils/gstnavseek.c @@ -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), ¤t, &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;