Ejemplo n.º 1
0
static void
player_forward_rewind (MexPlayer *player, gboolean increment)
{
  MexPlayerPrivate *priv = player->priv;

  gdouble duration;
  gfloat progress;

  duration = clutter_media_get_duration (priv->media);
  progress = clutter_media_get_progress (priv->media);

  /* If/when clutter gst supports trickmode we could implement
   *  that here instead
   * http://bugzilla.clutter-project.org/show_bug.cgi?id=2634
   */

  if (increment)
    progress = MIN (1.0, ((duration * progress) + 10) / duration);
  else
    progress = MAX (0.0, ((duration * progress) - 10) / duration);

  mex_player_set_controls_visible (player, TRUE);

  clutter_media_set_progress (priv->media, progress);
}
Ejemplo n.º 2
0
static void
media_eos_cb (ClutterMedia *media,
              MexPlayer    *player)
{
  MexPlayerPrivate *priv = player->priv;

  priv->position = 0.0;

  if (priv->idle_mode)
    {
      /* loop the video in idle mode */
      clutter_media_set_progress (media, priv->position);
      clutter_media_set_playing (media, TRUE);
    }
  else
    {
      /* set the control visible */
      mex_player_set_controls_visible (player, TRUE);

      clutter_media_set_progress (media, priv->position);
      clutter_media_set_playing (media, FALSE);

      /* focus the related content */
      mex_media_controls_focus_content (MEX_MEDIA_CONTROLS (priv->controls),
                                        priv->content);

      /* we're not playing the content or playing the idle video so allow
       * screensaver if previously inhibited */
      mex_screensaver_uninhibit (priv->screensaver);

      priv->current_position = 0.0;
      priv->at_eos = TRUE;
    }
}
Ejemplo n.º 3
0
/* 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;
}
Ejemplo n.º 4
0
void
mex_player_set_idle_mode (MexPlayer *player,
                          gboolean   idle)
{
  MexPlayerPrivate *priv = player->priv;

  if (priv->idle_mode == idle)
    return;

  priv->idle_mode = idle;

  mex_player_set_controls_visible (player, !idle);

  if (idle)
    {
      gchar *tmp;

      clutter_actor_hide (priv->controls);
      clutter_actor_hide (priv->info_panel);
      mx_widget_set_disabled (MX_WIDGET (player), TRUE);
      clutter_actor_set_reactive (CLUTTER_ACTOR (player), FALSE);

      if (priv->content) {
        save_old_content (player);
        g_object_unref (priv->content);
        priv->content = NULL;
      }

      tmp = g_strconcat ("file://", mex_get_data_dir (),
                         "/common/style/background-loop.mkv", NULL);
      clutter_media_set_uri (priv->media, tmp);
      g_free (tmp);

      clutter_media_set_playing (priv->media, TRUE);

      /* we're idle so we don't mind the screensaver coming on */
       mex_screensaver_uninhibit (priv->screensaver);
    }
  else
    {
      clutter_actor_show (priv->controls);
      clutter_actor_show (priv->info_panel);
      mx_widget_set_disabled (MX_WIDGET (player), FALSE);
      clutter_actor_set_reactive (CLUTTER_ACTOR (player), TRUE);
      clutter_media_set_playing (priv->media, FALSE);
      clutter_media_set_uri (priv->media, NULL);

      /* we're playing real content so don't allow the screensaver */
      mex_screensaver_inhibit (priv->screensaver);
    }
}
Ejemplo n.º 5
0
static void
media_eos_cb (ClutterMedia *media,
              MexPlayer    *player)
{
  MexPlayerPrivate *priv = player->priv;

  priv->position = 0.0;

  if (priv->idle_mode)
    {
      /* loop the video in idle mode */
      clutter_media_set_progress (media, priv->position);
      clutter_media_set_playing (media, TRUE);
    }
  else
    {
      /* Check to see if we have enqueued content and if so play it next */
      MexContent *enqueued_content;

      enqueued_content =
        mex_media_controls_get_enqueued (MEX_MEDIA_CONTROLS (priv->controls),
                                         priv->content);

      /* set the control visible */
      clutter_actor_animate (priv->info_panel, CLUTTER_EASE_IN_SINE,
                             250, "opacity", 0x00, NULL);
      mex_player_set_controls_visible (player, TRUE);

      if (enqueued_content)
        {
          priv->playing_from_queue = TRUE;
          mex_player_set_content (MEX_CONTENT_VIEW (player), enqueued_content);
        }
      else
        {
          priv->playing_from_queue = TRUE;
          mex_screensaver_uninhibit (priv->screensaver);

          clutter_media_set_progress (media, priv->position);
          clutter_media_set_playing (media, FALSE);

          priv->current_position = 0.0;
          priv->at_eos = TRUE;
        }

      /* focus the related content */
      mex_media_controls_focus_content (MEX_MEDIA_CONTROLS (priv->controls),
                                        priv->content);
    }
}
Ejemplo n.º 6
0
static gboolean
mex_hide_controls_cb (MexPlayer *player)
{
  MexPlayerPrivate *priv = player->priv;

  /* timer no longer running */
  priv->hide_controls_source = 0;
  /* if we've timed out then don't bring the controls
     up after the info panel has been visible */
  priv->controls_prev_visible = 0;

  /* hide the controls unless the video is at the end */
  if (!priv->at_eos)
    mex_player_set_controls_visible (player, FALSE);

  return FALSE;
}
Ejemplo n.º 7
0
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;
}
Ejemplo n.º 8
0
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;
}
Ejemplo n.º 9
0
/* 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;
    }
  }
}