mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 16:31:58 +02:00
mpris: Add "SupportedUriSchemes" and handle "OpenUri" method
This commit is contained in:
@@ -386,6 +386,22 @@ handle_set_position_cb (GstClapperMprisMediaPlayer2Player * player_skeleton,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
handle_open_uri_cb (GstClapperMprisMediaPlayer2Player * player_skeleton,
|
||||||
|
GDBusMethodInvocation * invocation, const gchar * uri,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GstClapper *clapper = GST_CLAPPER (user_data);
|
||||||
|
|
||||||
|
GST_DEBUG ("Handle OpenUri");
|
||||||
|
|
||||||
|
/* FIXME: set one item playlist instead */
|
||||||
|
gst_clapper_set_uri (clapper, uri);
|
||||||
|
gst_clapper_mpris_media_player2_player_complete_open_uri (player_skeleton, invocation);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
volume_notify_dispatch (gpointer user_data)
|
volume_notify_dispatch (gpointer user_data)
|
||||||
{
|
{
|
||||||
@@ -423,6 +439,47 @@ _get_mpris_trackid (GstClapperMpris * self)
|
|||||||
return g_strdup_printf ("%s%s%i", self->id_path, "/Track/", 0);
|
return g_strdup_printf ("%s%s%i", self->id_path, "/Track/", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_set_supported_uri_schemes (GstClapperMpris * self)
|
||||||
|
{
|
||||||
|
const gchar *uri_schemes[96] = {};
|
||||||
|
GList *elements, *el;
|
||||||
|
guint index = 0;
|
||||||
|
|
||||||
|
elements = gst_element_factory_list_get_elements (
|
||||||
|
GST_ELEMENT_FACTORY_TYPE_SRC, GST_RANK_NONE);
|
||||||
|
|
||||||
|
for (el = elements; el != NULL; el = el->next) {
|
||||||
|
const gchar *const *protocols;
|
||||||
|
GstElementFactory *factory = GST_ELEMENT_FACTORY (el->data);
|
||||||
|
|
||||||
|
if (gst_element_factory_get_uri_type (factory) != GST_URI_SRC)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
protocols = gst_element_factory_get_uri_protocols (factory);
|
||||||
|
if (protocols == NULL || *protocols == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
while (*protocols != NULL) {
|
||||||
|
guint j = index;
|
||||||
|
|
||||||
|
while (j--) {
|
||||||
|
if (strcmp (uri_schemes[j], *protocols) == 0)
|
||||||
|
goto next;
|
||||||
|
}
|
||||||
|
uri_schemes[index] = *protocols;
|
||||||
|
GST_DEBUG_OBJECT (self, "Added supported URI scheme: %s", *protocols);
|
||||||
|
++index;
|
||||||
|
next:
|
||||||
|
++protocols;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gst_plugin_feature_list_free (elements);
|
||||||
|
|
||||||
|
gst_clapper_mpris_media_player2_set_supported_uri_schemes (
|
||||||
|
self->base_skeleton, uri_schemes);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
name_acquired_cb (GDBusConnection * connection,
|
name_acquired_cb (GDBusConnection * connection,
|
||||||
const gchar *name, gpointer user_data)
|
const gchar *name, gpointer user_data)
|
||||||
@@ -440,6 +497,8 @@ name_acquired_cb (GDBusConnection * connection,
|
|||||||
if (self->desktop_entry)
|
if (self->desktop_entry)
|
||||||
gst_clapper_mpris_media_player2_set_desktop_entry (self->base_skeleton, self->desktop_entry);
|
gst_clapper_mpris_media_player2_set_desktop_entry (self->base_skeleton, self->desktop_entry);
|
||||||
|
|
||||||
|
_set_supported_uri_schemes (self);
|
||||||
|
|
||||||
gst_clapper_mpris_media_player2_player_set_playback_status (self->player_skeleton, "Stopped");
|
gst_clapper_mpris_media_player2_player_set_playback_status (self->player_skeleton, "Stopped");
|
||||||
gst_clapper_mpris_media_player2_player_set_minimum_rate (self->player_skeleton, 0.01);
|
gst_clapper_mpris_media_player2_player_set_minimum_rate (self->player_skeleton, 0.01);
|
||||||
gst_clapper_mpris_media_player2_player_set_maximum_rate (self->player_skeleton, 2.0);
|
gst_clapper_mpris_media_player2_player_set_maximum_rate (self->player_skeleton, 2.0);
|
||||||
@@ -642,6 +701,8 @@ gst_clapper_mpris_set_clapper (GstClapperMpris * self, GstClapper * clapper,
|
|||||||
G_CALLBACK (handle_seek_cb), clapper);
|
G_CALLBACK (handle_seek_cb), clapper);
|
||||||
g_signal_connect (self->player_skeleton, "handle-set-position",
|
g_signal_connect (self->player_skeleton, "handle-set-position",
|
||||||
G_CALLBACK (handle_set_position_cb), clapper);
|
G_CALLBACK (handle_set_position_cb), clapper);
|
||||||
|
g_signal_connect (self->player_skeleton, "handle-open-uri",
|
||||||
|
G_CALLBACK (handle_open_uri_cb), clapper);
|
||||||
|
|
||||||
g_object_bind_property (clapper, "volume", self, "volume", G_BINDING_BIDIRECTIONAL);
|
g_object_bind_property (clapper, "volume", self, "volume", G_BINDING_BIDIRECTIONAL);
|
||||||
g_signal_connect (self->player_skeleton, "notify::volume",
|
g_signal_connect (self->player_skeleton, "notify::volume",
|
||||||
|
Reference in New Issue
Block a user