void gb_player_pause (GbPlayer *self) { if (!self->priv->playing) return; gst_element_set_state (self->priv->player, GST_STATE_PAUSED); clutter_texture_set_pixbuf (CLUTTER_TEXTURE(self->priv->controls_play_pause), self->priv->play, NULL); g_object_set (self, "playing", FALSE, NULL); }
void on_click (ClutterActor *actor, ClutterEvent *event, gpointer data) { HandCar *all = (HandCar *)data; gint x, y; gint64 pos = -1; clutter_event_get_coords (event, &x, &y); if (coord_within_actor (all->btn_actor_play, x, y)) { if (!all->playing) { play_video (all); clutter_texture_set_pixbuf (CLUTTER_TEXTURE(all->btn_actor_play), all->stop, NULL); all->playing = TRUE; } else { stop_video (all); clutter_texture_set_pixbuf (CLUTTER_TEXTURE(all->btn_actor_play), all->play, NULL); all->playing = FALSE; } } else if ((coord_within_actor (all->btn_actor_next, x, y) && (all->playing))) { if (!gst_element_query_position (all->player, &all->format, &pos)) pos = 0; gst_element_seek_simple (all->player, all->format, GST_SEEK_FLAG_FLUSH, pos + 5 * GST_SECOND); } else if ((coord_within_actor (all->btn_actor_previous, x, y) && (all->playing))) { if (!gst_element_query_position (all->player, &all->format, &pos)) pos = 5 * GST_SECOND; gst_element_seek_simple (all->player, all->format, GST_SEEK_FLAG_FLUSH, pos - 5 * GST_SECOND); } }
/* Fade out text, change text, then fade in, all within one play of the timeline just to keep things interesting :) */ static void fluttr_viewer_swap_alpha_func (ClutterBehaviour *behave, guint alpha_value, gpointer data) { FluttrViewerPrivate *priv; gfloat factor; guint width = CLUTTER_STAGE_WIDTH (); guint height = CLUTTER_STAGE_HEIGHT (); guint w, h; g_return_if_fail (FLUTTR_IS_VIEWER (data)); priv = FLUTTR_VIEWER_GET_PRIVATE(data); factor = (gfloat) alpha_value / CLUTTER_ALPHA_MAX_ALPHA; if (priv->pixbuf != NULL && factor > 0.5) { clutter_texture_set_pixbuf (CLUTTER_TEXTURE (priv->texture), priv->pixbuf, NULL); clutter_actor_get_size (priv->texture, &w, &h); clutter_actor_set_position (priv->texture, (width/2) - (w/2), (height/2) - (h/2)); } if (factor < 0.5) { factor *= 2; factor = 1.0 - factor; } else { factor -= 0.5; factor /= 0.5; } clutter_actor_set_opacity (CLUTTER_ACTOR (priv->texture), 255 * factor); clutter_actor_set_opacity (priv->spinner, 255 * (1-factor)); if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR(data))) clutter_actor_queue_redraw (CLUTTER_ACTOR(data)); }
void gb_player_play (GbPlayer *self) { GtkWidget *dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW(self->priv->window), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Choose a valid file to play before clicking the f*****g play!", NULL); if (!self->priv->filename) { gtk_dialog_run (GTK_DIALOG(dialog)); return; } if (self->priv->playing) return; g_object_set (self->priv->player, "uri", self->priv->filename, NULL); gst_element_set_state (self->priv->player, GST_STATE_PLAYING); clutter_texture_set_pixbuf (CLUTTER_TEXTURE(self->priv->controls_play_pause), self->priv->stop, NULL); g_object_set (self, "playing", TRUE, NULL); }