コード例 #1
0
static void
mex_volume_control_init (MexVolumeControl *self)
{
  MexVolumeControlPrivate *priv = self->priv = VOLUME_CONTROL_PRIVATE (self);
  gchar *new_style_class;
  MexPlayer *player;
  MexMusicPlayer *music;

  player = mex_player_get_default ();
  priv->media = mex_player_get_clutter_media (player);

  music = mex_music_player_get_default ();
  priv->music = mex_music_player_get_clutter_media (music);

  priv->volume = mx_button_new ();
  mx_widget_set_disabled (MX_WIDGET (priv->volume), TRUE);

  priv->vol_value = clutter_media_get_audio_volume (priv->media);

  /* The media sound can also be changed from another process changint the
   * stream audio with pulse audio, adjust the volume on those changes */
  g_signal_connect (priv->media, "notify::audio-volume",
                    G_CALLBACK (on_audio_volume_changed), self);
  g_signal_connect (priv->music, "notify::audio-volume",
                    G_CALLBACK (on_audio_volume_changed), self);

  new_style_class = g_strdup_printf ("volume-%.0f", priv->vol_value * 10);

  mx_stylable_set_style_class (MX_STYLABLE (priv->volume), new_style_class);
  g_free (new_style_class);

  clutter_actor_add_child (CLUTTER_ACTOR (self), priv->volume);
}
コード例 #2
0
static void
mex_mpris_plugin_init (MexMprisPlugin *self)
{
  MexMprisPluginPrivate *priv = self->priv =
    MPRIS_PLUGIN_PRIVATE (self);

  GError *error=NULL;
  priv->player = mex_player_get_default ();
  priv->media = mex_player_get_clutter_media (priv->player);

  g_signal_connect (priv->media,
                    "notify::in-seek",
                    G_CALLBACK (_check_if_seeked),
                    self);

  g_bus_own_name (G_BUS_TYPE_SESSION,
                  MPRIS_BUS_NAME_PREFIX ".media-explorer",
                  G_BUS_NAME_OWNER_FLAGS_NONE,
                  NULL,
                  NULL,
                  NULL,
                  NULL,
                  NULL);

  if (!(priv->introspection_data = g_dbus_node_info_new_for_xml (mpris_introspection_xml, &error)))
      g_warning ("Error %s", error->message);


  g_bus_get (G_BUS_TYPE_SESSION, NULL, on_bus_acquired, self);

  priv->mimes_supported = g_strsplit (MEX_MIME_TYPES, ";", -1);
}
コード例 #3
0
static gboolean
_set_player_property_cb (GDBusConnection  *connection,
                         const gchar      *sender,
                         const gchar      *object_path,
                         const gchar      *interface_name,
                         const gchar      *property_name,
                         GVariant         *value,
                         GError           **error,
                         gpointer          user_data)
{
  MexMprisPluginPrivate *priv = MEX_MPRIS_PLUGIN (user_data)->priv;

  /* Currently unsupported properties */
  if (g_strcmp0 (property_name, "LoopStatus") == 0 ||
      g_strcmp0 (property_name, "Rate") == 0 ||
      g_strcmp0 (property_name, "Shuffle") == 0)
    return FALSE;

  if (g_strcmp0 (property_name, "Volume") == 0)
    {
      ClutterMedia *media;

      if (mex_music_player_is_playing (priv->music))
        media = mex_music_player_get_clutter_media (priv->music);
      else
        media = mex_player_get_clutter_media (priv->player);

      clutter_media_set_audio_volume (media, g_variant_get_double (value));
      return TRUE;
    }

  g_set_error (error,
               G_DBUS_ERROR,
               G_DBUS_ERROR_NOT_SUPPORTED,
               "Property %s.%s not supported",
               interface_name,
               property_name);

  return FALSE;
}
コード例 #4
0
static gboolean
_start_video_preview (MexContentTile *self)
{
  MexContentTilePrivate *priv = self->priv;
  GstElement *pipeline;
  gint gst_flags;

  const gchar *mimetype, *uri;

  /* Check we're still focused */
  if (!mex_actor_has_focus (CLUTTER_ACTOR (self)))
    return FALSE;

  /* Don't play if the main player is still playing..
   * too many videos spoil the broth.
   */
  if (clutter_media_get_playing (mex_player_get_clutter_media (mex_player_get_default ())))
    return FALSE;

  mimetype = mex_content_get_metadata (priv->content,
                                       MEX_CONTENT_METADATA_MIMETYPE);

  if ((mimetype) && strncmp (mimetype, "video/", 6) != 0)
    return FALSE;

  if (!(uri = mex_content_get_metadata (priv->content,
                                        MEX_CONTENT_METADATA_STREAM)))
    return FALSE;

  priv->video_preview = clutter_gst_video_texture_new ();

  pipeline = clutter_gst_video_texture_get_pipeline (CLUTTER_GST_VIDEO_TEXTURE (priv->video_preview));
  g_object_get (G_OBJECT (pipeline), "flags", &gst_flags, NULL);

  gst_flags = 1;//GST_PLAY_FLAG_VIDEO;

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


  clutter_gst_video_texture_set_idle_material (CLUTTER_GST_VIDEO_TEXTURE (priv->video_preview),
                                               NULL);
  g_signal_connect (priv->video_preview, "eos",
                    G_CALLBACK (_stop_video_eos),
                    self);

  clutter_actor_set_opacity (priv->video_preview, 0);

  g_object_ref (priv->image);
  clutter_actor_remove_child (CLUTTER_ACTOR (self), priv->image);
  clutter_actor_add_child (CLUTTER_ACTOR (self), priv->video_preview);


  clutter_actor_animate (priv->video_preview, CLUTTER_LINEAR, 500,
                         "opacity", 0xff, NULL);

  clutter_actor_set_size (priv->video_preview,
                          (gfloat)priv->thumb_width,
                          (gfloat)priv->thumb_height);

  clutter_media_set_uri (CLUTTER_MEDIA (priv->video_preview), uri);
  clutter_media_set_playing (CLUTTER_MEDIA (priv->video_preview), TRUE);

  if (priv->stop_video_preview <= 0)
    priv->stop_video_preview =
      g_timeout_add_seconds (180, (GSourceFunc)_stop_video_preview, self);

  return FALSE;
}
コード例 #5
0
static GVariant *
_get_player_property_cb (GDBusConnection  *connection,
                         const gchar      *sender,
                         const gchar      *object_path,
                         const gchar      *interface_name,
                         const gchar      *property_name,
                         GError          **error,
                         gpointer          user_data)
{
  MexMprisPluginPrivate *priv = MEX_MPRIS_PLUGIN (user_data)->priv;
  ClutterMedia *media;
  GVariant *v = NULL;

  if (mex_music_player_is_playing (priv->music))
    media = mex_music_player_get_clutter_media (priv->music);
  else
    media = mex_player_get_clutter_media (priv->player);

  if (g_strcmp0 ("PlaybackStatus", property_name) == 0)
    {
      /* Doesn't map to ClutterMedia straight away so try to emulate.
       * Playback could theoretically be paused at progress 0.0 but well ...*/
      gdouble progress = clutter_media_get_progress (media);
      gboolean playing = clutter_media_get_playing (media);

      if (playing)
          v = g_variant_new_string ("Playing");
      else if (progress != 0)
          v = g_variant_new_string ("Paused");
       else
          v = g_variant_new_string ("Stopped");
    }

  else if (g_strcmp0 ("LoopStatus", property_name) == 0)
    v = g_variant_new_string ("None");

  else if (g_strcmp0 ("Rate", property_name) == 0 ||
           g_strcmp0 ("MinimumRate", property_name)  == 0 ||
           g_strcmp0 ("MinimumRate", property_name) == 0 )
    v = g_variant_new_double (1.0);

  else if (g_strcmp0 ("Shuffle", property_name) == 0)
    v = g_variant_new_boolean (FALSE);

  else if (g_strcmp0 ("Volume", property_name) == 0)
    v = g_variant_new_double (clutter_media_get_audio_volume (media));

  else if (g_strcmp0 ("Position", property_name) == 0)
    {
      gdouble duration_s = clutter_media_get_duration (media);
      gdouble progress_rel = clutter_media_get_progress (media);
      gint64 position_ms = duration_s * 1000000 * progress_rel;
      v = g_variant_new_int64 (position_ms);
    }

  else if (g_strcmp0 ("CanGoNext", property_name) == 0 ||
           g_strcmp0 ("CanGoPrevious", property_name) == 0 ||
           g_strcmp0 ("CanPlay", property_name) == 0 ||
           g_strcmp0 ("CanControl", property_name) == 0 ||
           g_strcmp0 ("CanPause", property_name) == 0)
    v = g_variant_new_boolean (TRUE);

  else if (g_strcmp0 ("CanSeek", property_name) == 0)
    v = g_variant_new_boolean (clutter_media_get_can_seek (media));

  if (v)
    return v;

  g_set_error (error,
               G_DBUS_ERROR,
               G_DBUS_ERROR_NOT_SUPPORTED,
               "Property %s.%s not supported",
               interface_name,
               property_name);
  return NULL;
}