Exemplo n.º 1
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;
    }
}
Exemplo 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
    {
      /* 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);
    }
}
Exemplo n.º 3
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);
}
Exemplo n.º 4
0
static gboolean
key_press_timeout_cb (gpointer data)
{
    MexMediaControlsPrivate *priv = MEX_MEDIA_CONTROLS (data)->priv;
    gdouble duration;
    gdouble change;
    gfloat progress;

    priv->long_press_activated = TRUE;

    priv->key_press_count++;

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

    if (priv->key_press_count >= 10)
        change = 60;
    else
        change = 10;

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

    clutter_media_set_progress (priv->media, progress);

    return TRUE;
}
Exemplo n.º 5
0
static void
mex_music_player_slider_notify (MxSlider       *slider,
                                GParamSpec     *pspec,
                                MexMusicPlayer *player)
{
  MexMusicPlayerPrivate *priv = player->priv;

  clutter_media_set_progress (priv->player,
                              mx_slider_get_value (MX_SLIDER (priv->slider)));
}
Exemplo n.º 6
0
void
mex_player_previous (MexPlayer *player)
{
  MexPlayerPrivate *priv = player->priv;

  if (priv->idle_mode)
    return;

  clutter_media_set_progress (priv->media, 0.0);
}
Exemplo n.º 7
0
static int mp_seek(TPMediaPlayer * mp,double seconds)
{
    USERDATA(mp);
    CM(ud);

    if (!clutter_media_get_can_seek(cm))
        return 1;
    clutter_media_set_progress(cm,seconds/clutter_media_get_duration(cm));
    return 0;
}
Exemplo n.º 8
0
static void
slider_value_changed_cb (MxSlider         *slider,
                         GParamSpec       *pspec,
                         MexMediaControls *controls)
{
    MexMediaControlsPrivate *priv = controls->priv;

    if (priv->media)
        clutter_media_set_progress (priv->media,
                                    mx_slider_get_value (MX_SLIDER (priv->slider)));
}
Exemplo n.º 9
0
static void
mex_get_stream_cb (MexProgram   *program,
                   const gchar  *url,
                   const GError *error,
                   gpointer      user_data)
{
  MexPlayer *player = user_data;
  MexPlayerPrivate *priv = player->priv;
  MexGenericContent  *generic_content;
#ifdef USE_PLAYER_CLUTTER_GST
  ClutterGstVideoTexture *video_texture;
#endif

  /* if idle mode has been set before the program stream was found */
  if (priv->idle_mode)
    return;

  if (G_UNLIKELY (error))
    {
      g_warning ("Could not play content: %s (%s)", error->message, url);
      return;
    }

#ifdef USE_PLAYER_CLUTTER_GST
  /* We seek at the precise time when the file is local, but we
   * seek to key frame when streaming */
  video_texture = CLUTTER_GST_VIDEO_TEXTURE (priv->media);
  if (g_str_has_prefix (url, "file://"))
    {
      clutter_gst_video_texture_set_seek_flags (video_texture,
                                                CLUTTER_GST_SEEK_FLAG_ACCURATE);
    }
  else
    {
      clutter_gst_video_texture_set_seek_flags (video_texture,
                                                CLUTTER_GST_SEEK_FLAG_NONE);
    }
#endif

  clutter_media_set_uri (CLUTTER_MEDIA (priv->media), url);
  generic_content = MEX_GENERIC_CONTENT (priv->content);
  if (mex_generic_content_get_last_position_start (generic_content))
    clutter_media_set_progress (CLUTTER_MEDIA (priv->media), priv->position);
  clutter_media_set_playing (CLUTTER_MEDIA (priv->media), TRUE);
}
Exemplo n.º 10
0
static void mp_reset(TPMediaPlayer * mp)
{
    USERDATA(mp);
    CM(ud);

    disconnect_loading_messages(mp);

    ud->video_width=0;
    ud->video_height=0;
    ud->media_type=0;

    // Reset should do more - it should truly forget all about the resource

    clutter_media_set_playing(cm,FALSE);
    clutter_media_set_progress(cm,0);

    clutter_actor_hide(CLUTTER_ACTOR(cm));
}
Exemplo n.º 11
0
void
mex_music_player_seek_us (MexMusicPlayer *player, gint64 seek_offset_us)
{
  MexMusicPlayerPrivate *priv;
  gdouble duration_us, progress, new_progress;

  g_return_if_fail (MEX_IS_MUSIC_PLAYER (player));

  priv = player->priv;

  duration_us = clutter_media_get_duration (priv->player) * 1000000;
  progress = clutter_media_get_progress (priv->player) * duration_us;

  new_progress = (progress + seek_offset_us) / duration_us;

  if (new_progress < 0.0)
    mex_music_player_previous (player);
  else if (new_progress > 1.0)
    mex_music_player_next (player);
  else
    clutter_media_set_progress (priv->player, new_progress);
}
Exemplo n.º 12
0
static void
mex_get_stream_cb (MexProgram   *program,
                   const gchar  *url,
                   const GError *error,
                   gpointer      user_data)
{
  MexPlayer *player = user_data;
  MexPlayerPrivate *priv = player->priv;
  MexGenericContent  *generic_content;
#ifdef USE_PLAYER_CLUTTER_GST
  ClutterGstVideoTexture *video_texture;
#endif

  /* if idle mode has been set before the program stream was found */
  if (priv->idle_mode)
    return;

  if (G_UNLIKELY (error))
    {
      g_warning ("Could not play content: %s (%s)", error->message, url);
      return;
    }

#ifdef USE_PLAYER_CLUTTER_GST
  /* We seek at the precise time when the file is local, but we
   * seek to key frame when streaming */
  video_texture = CLUTTER_GST_VIDEO_TEXTURE (priv->media);
  if (g_str_has_prefix (url, "file://"))
    {
      clutter_gst_video_texture_set_seek_flags (video_texture,
                                                CLUTTER_GST_SEEK_FLAG_ACCURATE);
    }
  else
    {
      clutter_gst_video_texture_set_seek_flags (video_texture,
                                                CLUTTER_GST_SEEK_FLAG_NONE);
    }

  /* TODO when we have settings we can configure this feature */

  if (g_str_has_prefix (mex_content_get_metadata (priv->content,
                                                  MEX_CONTENT_METADATA_MIMETYPE),
                        "audio/"))
    {
      GstElement *gst_element, *visual;
      gint gst_flags;

      gst_element = clutter_gst_video_texture_get_pipeline (video_texture);
      g_object_get (G_OBJECT (gst_element), "flags", &gst_flags, NULL);

      gst_flags = (GST_PLAY_FLAG_VIS | gst_flags);

      g_object_set (G_OBJECT (gst_element), "flags", gst_flags, NULL);

      visual = gst_element_factory_make ("libvisual_infinite", NULL);

      if (visual)
        g_object_set (G_OBJECT (gst_element), "vis-plugin", visual, NULL);
    }
#endif

  clutter_media_set_uri (CLUTTER_MEDIA (priv->media), url);
  generic_content = MEX_GENERIC_CONTENT (priv->content);
  if (mex_generic_content_get_last_position_start (generic_content))
    clutter_media_set_progress (CLUTTER_MEDIA (priv->media), priv->position);
  clutter_media_set_playing (CLUTTER_MEDIA (priv->media), TRUE);
}