toggle playback when button clicked

This commit is contained in:
Brandon Lewis 2010-07-22 12:17:24 +02:00 committed by Edward Hervey
parent 5cbd2f28a6
commit 783ce7ac3b
2 changed files with 22 additions and 0 deletions

View file

@ -36,6 +36,7 @@ typedef struct App
GtkHScale *duration;
GtkHScale *in_point;
GtkMenuItem *delete_item;
GstState state;
} App;
App *app_new (void);
@ -56,10 +57,14 @@ void quit_item_activate_cb (GtkMenuItem * item, App * app);
void delete_activate_cb (GtkAction * item, App * app);
void play_activate_cb (GtkAction * item, App * app);
void add_file_activate_cb (GtkAction * item, App * app);
void app_selection_changed_cb (GtkTreeSelection * selection, App * app);
void app_toggle_playback (App * app);
gboolean duration_scale_change_value_cb (GtkRange * range, GtkScrollType
unused, gdouble value, App * app);
@ -108,6 +113,12 @@ add_file_activate_cb (GtkAction * item, App * app)
app_add_file (app, (gchar *) "/home/brandon/media/small-mvi_0008.avi");
}
void
play_activate_cb (GtkAction * item, App * app)
{
app_toggle_playback (app);
}
void
app_selection_changed_cb (GtkTreeSelection * selection, App * app)
{
@ -168,6 +179,16 @@ duration_cell_func (GtkTreeViewColumn * column, GtkCellRenderer * renderer,
static void selection_foreach (GtkTreeModel * model, GtkTreePath * path,
GtkTreeIter * iter, gpointer user);
void
app_toggle_playback (App * app)
{
if (app->state != GST_STATE_PLAYING) {
gst_element_set_state (GST_ELEMENT (app->pipeline), GST_STATE_PLAYING);
} else {
gst_element_set_state (GST_ELEMENT (app->pipeline), GST_STATE_PAUSED);
}
}
void
app_update_selection (App * app)
{

View file

@ -417,5 +417,6 @@
<property name="label">Play</property>
<property name="stock_id">gtk-media-play</property>
<property name="always_show_image">True</property>
<signal name="activate" handler="play_activate_cb"/>
</object>
</interface>