static gboolean mex_player_captured_event (ClutterActor *actor, ClutterEvent *event) { MexPlayerPrivate *priv = MEX_PLAYER (actor)->priv; if (!priv->controls_prev_visible) mex_player_restart_timer (MEX_PLAYER (actor)); return FALSE; }
/* MxFocusable implementation */ static MxFocusable * mex_player_move_focus (MxFocusable *focusable, MxFocusDirection direction, MxFocusable *old_focus) { if (direction == MX_FOCUS_DIRECTION_UP) mex_player_set_controls_visible (MEX_PLAYER (focusable), FALSE); return NULL; }
static void mex_player_dispose (GObject *object) { MexPlayer *player = MEX_PLAYER (object); MexPlayerPrivate *priv = player->priv; if (priv->content) { g_object_unref (priv->content); priv->content = NULL; } if (priv->model) { g_object_unref (priv->model); priv->model = NULL; } if (priv->media) { g_signal_handlers_disconnect_by_func (priv->media, media_eos_cb, player); g_signal_handlers_disconnect_by_func (priv->media, media_playing_cb, player); g_signal_handlers_disconnect_by_func (priv->media, media_update_progress, player); g_object_unref (priv->media); priv->media = NULL; } if (priv->screensaver) { g_object_unref (priv->screensaver); priv->screensaver = NULL; } if (priv->related_tile) { g_object_unref (priv->related_tile); priv->related_tile = NULL; } #if defined(USE_PLAYER_CLUTTER_GST) || defined(USE_PLAYER_SURFACE) if (priv->bridge) { g_object_unref (priv->bridge); priv->bridge = NULL; } #endif G_OBJECT_CLASS (mex_player_parent_class)->dispose (object); }
static gboolean mex_player_captured_event (ClutterActor *actor, ClutterEvent *event) { MexPlayer *self = MEX_PLAYER (actor); MexPlayerPrivate *priv = self->priv; /* Do nothing if the info panel is up */ if (priv->controls_prev_visible) return FALSE; /* If a mouse button was pressed and the controls aren't visible, show them, * otherwise restart the control-showing timer. */ if ((event->type == CLUTTER_BUTTON_PRESS) && !priv->controls_visible) mex_player_set_controls_visible (self, TRUE); else mex_player_restart_timer (MEX_PLAYER (actor)); return FALSE; }
static void mex_player_set_context (MexContentView *player, MexModel *model) { MexPlayerPrivate *priv = MEX_PLAYER (player)->priv; if (priv->model) g_object_unref (priv->model); priv->model = model; if (model) g_object_ref (model); }
static void mex_player_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { switch (property_id) { case PROP_IDLE_MODE: mex_player_set_idle_mode (MEX_PLAYER (object), g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
static void mex_player_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { MexPlayerPrivate *priv = MEX_PLAYER (object)->priv; switch (property_id) { case PROP_IDLE_MODE: g_value_set_boolean (value, priv->idle_mode); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
static void mex_player_init (MexPlayer *self) { MexPlayerPrivate *priv; self->priv = priv = PLAYER_PRIVATE (self); #ifdef USE_PLAYER_CLUTTER_GST priv->media = (ClutterMedia *) clutter_gst_video_texture_new (); /* We want to keep a reference to the media here to ensure consistency with * the D-BUS client interface behaviour */ g_object_ref_sink (priv->media); clutter_container_add_actor (CLUTTER_CONTAINER (self), CLUTTER_ACTOR (priv->media)); clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->media), TRUE); clutter_container_child_set (CLUTTER_CONTAINER (self), CLUTTER_ACTOR (priv->media), "fit", TRUE, NULL); /* Use progressive download when possible. Don't enable that yet, the * behaviour of seeking in the non already downloaded part of the stream * is not great. Either disable seeking in that case or find out why.*/ #if 0 video_texture = CLUTTER_GST_VIDEO_TEXTURE (priv->media); clutter_gst_video_texture_set_buffering_mode (video_texture, CLUTTER_GST_BUFFERING_MODE_DOWNLOAD); #endif #else #ifdef USE_PLAYER_DBUS priv->media = (ClutterMedia *) mex_player_client_new (); #else #ifdef USE_PLAYER_SURFACE priv->media = (ClutterMedia *) mex_surface_player_new (); #else #error Unexpected player setup #endif #endif #endif g_signal_connect (priv->media, "eos", G_CALLBACK (media_eos_cb), self); g_signal_connect (priv->media, "notify::playing", G_CALLBACK (media_playing_cb), self); g_signal_connect (priv->media, "notify::progress", G_CALLBACK (media_update_progress), self); #if defined(USE_PLAYER_SURFACE) || defined (USE_PLAYER_CLUTTER_GST) { GError *error = NULL; priv->bridge = mex_media_dbus_bridge_new (priv->media); if (!mex_media_dbus_bridge_register (priv->bridge, &error)) { g_warning (G_STRLOC ": Error registering player on D-BUS"); g_clear_error (&error); } } #endif /* add info panel */ priv->info_panel = mex_info_panel_new (MEX_INFO_PANEL_MODE_FULL); mx_widget_set_disabled (MX_WIDGET (priv->info_panel), TRUE); clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->info_panel); clutter_container_child_set (CLUTTER_CONTAINER (self), priv->info_panel, "y-fill", FALSE, "y-align", MX_ALIGN_END, NULL); clutter_actor_set_opacity (priv->info_panel, 0); /* add media controls */ priv->controls = mex_media_controls_new (); g_signal_connect (priv->controls, "stopped", G_CALLBACK (controls_stopped_cb), self); mex_media_controls_set_media (MEX_MEDIA_CONTROLS (priv->controls), priv->media); clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->controls); clutter_container_child_set (CLUTTER_CONTAINER (self), priv->controls, "y-fill", FALSE, "y-align", MX_ALIGN_END, NULL); priv->screensaver = mex_screensaver_new (); /* start in idle mode */ mex_player_set_idle_mode (MEX_PLAYER (self), TRUE); }
static gboolean mex_player_key_press_event (ClutterActor *actor, ClutterKeyEvent *event) { MexPlayerPrivate *priv = MEX_PLAYER (actor)->priv; ClutterStage *stage; MxFocusManager *fmanager; stage = (ClutterStage*) clutter_actor_get_stage (actor); fmanager = mx_focus_manager_get_for_stage (stage); switch (event->keyval) { case CLUTTER_KEY_Down: { if (!priv->controls_visible && !priv->info_visible) return mex_player_set_controls_visible (MEX_PLAYER (actor), TRUE); break; } case MEX_KEY_INFO: { MexContent *content; content = priv->content; if (priv->info_visible) { /* hide the info panel */ clutter_actor_animate (priv->info_panel, CLUTTER_EASE_IN_SINE, 250, "opacity", 0x00, NULL); mx_widget_set_disabled (MX_WIDGET (priv->info_panel), TRUE); mx_widget_set_disabled (MX_WIDGET (priv->controls), FALSE); priv->info_visible = FALSE; if (priv->controls_prev_visible) mex_player_set_controls_visible (MEX_PLAYER (actor), TRUE); } else { /* if you're pressing info button while the media controls are up set them as previously visible */ if (priv->controls_visible) priv->controls_prev_visible = TRUE; MxFocusable *focusable; focusable = mx_focus_manager_get_focused (fmanager); if (MEX_IS_CONTENT_TILE (focusable) && priv->controls_prev_visible == TRUE) { content = mex_content_view_get_content (MEX_CONTENT_VIEW (focusable)); /* to avoid any accidental leak */ if (priv->related_tile) { g_object_unref (priv->related_tile); priv->related_tile = NULL; } priv->related_tile = g_object_ref (focusable); } mex_content_view_set_content (MEX_CONTENT_VIEW (priv->info_panel), content); /* show the info panel */ clutter_actor_animate (priv->info_panel, CLUTTER_EASE_IN_SINE, 250, "opacity", 0xff, NULL); mx_widget_set_disabled (MX_WIDGET (priv->info_panel), FALSE); mx_widget_set_disabled (MX_WIDGET (priv->controls), TRUE); priv->info_visible = TRUE; mex_player_set_controls_visible (MEX_PLAYER (actor), FALSE); mex_push_focus (MX_FOCUSABLE (priv->info_panel)); } return TRUE; } } return FALSE; }
static MexModel* mex_player_get_context (MexContentView *view) { return MEX_PLAYER (view)->priv->model; }
static MexContent * mex_player_get_content (MexContentView *player) { return MEX_PLAYER (player)->priv->content; }
/* MexContentView implementation */ static void mex_player_set_content (MexContentView *view, MexContent *content) { MexPlayerPrivate *priv = MEX_PLAYER (view)->priv; if (priv->model) mex_media_controls_set_content (MEX_MEDIA_CONTROLS (priv->controls), content, priv->model); if (priv->related_tile) { g_object_unref (priv->related_tile); priv->related_tile = NULL; } if (content) { const gchar *sposition, *sduration; if (priv->content) { save_old_content (MEX_PLAYER (view)); g_object_unref (priv->content); priv->content = NULL; } priv->content = g_object_ref_sink (content); sposition = mex_content_get_metadata (content, MEX_CONTENT_METADATA_LAST_POSITION); sduration = mex_content_get_metadata (content, MEX_CONTENT_METADATA_DURATION); if (sduration && !mex_media_controls_get_playing_queue (MEX_MEDIA_CONTROLS (priv->controls))) priv->duration = atoi (sduration); else priv->duration = 0; if (priv->duration > 0) { if (sposition) { int position = atoi (sposition); priv->position = (gdouble) position / (gdouble) priv->duration; } else { priv->position = 0.0; } } if (MEX_IS_PROGRAM (content)) { mex_program_get_stream (MEX_PROGRAM (content), mex_get_stream_cb, view); } else { const gchar *uri; uri = mex_content_get_metadata (content, MEX_CONTENT_METADATA_STREAM); mex_get_stream_cb (NULL, uri, NULL, view); } if (priv->info_visible) { clutter_actor_animate (priv->info_panel, CLUTTER_EASE_IN_SINE, 250, "opacity", 0x00, NULL); mx_widget_set_disabled (MX_WIDGET (priv->info_panel), TRUE); priv->info_visible = FALSE; } mex_player_set_controls_visible (MEX_PLAYER (view), TRUE); } else { if (priv->content) { g_object_unref (priv->content); priv->content = NULL; } } }