RE: Problem With File Browsing through Grilo
- From: "Rakesh Dhanya (RBEI/ECP2)" <Rakesh Dhanya in bosch com>
- To: "grilo-list gnome org" <grilo-list gnome org>
- Subject: RE: Problem With File Browsing through Grilo
- Date: Wed, 13 Jun 2012 17:36:15 +0800
Please find a sample code attached
_____________________________________________
From: Rakesh Dhanya (RBEI/ECP2)
Sent: Wednesday, 13. June 2012 2:58 PM
To: 'grilo-list gnome org'
Subject: Problem With File Browsing through Grilo
Hello,
I have been using Grilo from last week to try and build a media application. I am facing some problems
1. if I use grl-filesystem plugin, the metadata for many audio files is being printed as NULL. (It prints for some files and is blank for some others)
2. If I use grl-tracker plugin, then there are no results (Despite configuring tracker to search in specific folders through tracker-preferences it always looks for files in /usr)
Am I missing something here?
Please do let me know
Thanks and Best regards,
Rakesh
#include <glib.h>
#include <string.h>
#include <grilo.h>
static void browse_cb (GrlMediaSource *source,
guint browse_id,
GrlMedia *media,
guint remaining,
gpointer user_data,
const GError *error)
{
if (media) {
/* Get the metadata we are interested in */
const gchar *title = grl_media_get_title (media);
if (GRL_IS_MEDIA_BOX (media)) {
guint childcount = grl_media_box_get_childcount (GRL_MEDIA_BOX (media));
//g_print ("Got '%s' (container with %d elements) \n", title, childcount);
} else {
guint seconds = grl_media_get_duration (media);
const gchar *url = grl_media_get_url (media);
const gchar *mime = grl_media_get_mime (media);
const gchar *thumbnail = grl_media_get_thumbnail (media);
const gchar *author = grl_media_get_author (media);
const gchar *date = grl_media_get_date (media);
const gchar *artist = grl_media_audio_get_artist((GrlMediaAudio *)media);
g_print("Found New Media \n");
g_print("Url = %s, mime= %s, author = %s, duration = %d, date = %s, thumbnail = %s artist = %s \n", url, mime, author, seconds, date, thumbnail, artist);
}
g_object_unref (media);
}
if (remaining == 0) {
g_print ("Browse operation finished! \n");
}
}
static GrlMedia * media_from_id (const gchar *id)
{
GrlMedia *media;
media = grl_media_new ();
grl_media_set_id (media, id);
return media;
}
static void source_added_cb (GrlPluginRegistry *registry, gpointer user_data)
{
GrlMetadataSource *source = GRL_METADATA_SOURCE (user_data);
GList * keys = grl_metadata_key_list_new (GRL_METADATA_KEY_TITLE,
GRL_METADATA_KEY_DURATION,
GRL_METADATA_KEY_URL,
GRL_METADATA_KEY_CHILDCOUNT,
GRL_METADATA_KEY_MIME,
GRL_METADATA_KEY_THUMBNAIL,
GRL_METADATA_KEY_ALBUM,
GRL_METADATA_KEY_ARTIST,
GRL_METADATA_KEY_DATE,
NULL);
g_print ("Detected new source available: '%s' \n", grl_metadata_source_get_name (source));
//if ( (g_strcmp0(grl_metadata_source_get_name (source), "Tracker") == 0) && grl_metadata_source_supported_operations (source) & GRL_OP_BROWSE)
if ( (g_strcmp0(grl_metadata_source_get_name (source), "Filesystem") == 0) && grl_metadata_source_supported_operations (source) & GRL_OP_BROWSE)
{ g_print ("Browsing source: %s \n", grl_metadata_source_get_name (source));
/*grl_media_source_browse (GRL_MEDIA_SOURCE (source),
media_from_id("/home/rakesh/media/audio/"),
keys,
0, 500,
GRL_RESOLVE_IDLE_RELAY | GRL_RESOLVE_FULL,
browse_cb,
NULL); */
GError *error = NULL;
GList *mediaList = grl_media_source_browse_sync (GRL_MEDIA_SOURCE (source), media_from_id("<Path to Media Files >"), keys, 0, 10, GRL_RESOLVE_IDLE_RELAY | GRL_RESOLVE_FULL, &error);
//GList *mediaList = grl_media_source_browse_sync (GRL_MEDIA_SOURCE (source), NULL, keys, 0, 5, GRL_RESOLVE_IDLE_RELAY | GRL_RESOLVE_FULL, &error);
if( (NULL == error) && (NULL != mediaList))
{
g_print("No error, got %d files from grilo \n", g_list_length(mediaList));
GList *localList = g_list_first(mediaList);
while( (NULL != localList) && (NULL != localList->data) )
{
GrlMedia* media = (GrlMedia *)localList->data;
g_print("URI = %s, Title = %s, Mime = %s, Artist = %s, Album = %s, AlbumArt =%s \n", grl_media_get_url(media), grl_media_get_title(media), grl_media_get_mime(media), grl_media_audio_get_artist( (GrlMediaAudio *) media), grl_media_audio_get_album( (GrlMediaAudio *)media), grl_media_get_thumbnail(media));
localList = g_list_next(localList);
}
}
}
g_list_free (keys);
}
static void load_plugins (void)
{
GrlPluginRegistry *registry;
GError *error = NULL;
registry = grl_plugin_registry_get_default ();
g_signal_connect (registry, "source-added",
G_CALLBACK (source_added_cb), NULL);
if (!grl_plugin_registry_load_all (registry, &error)) {
g_error ("Failed to load plugins: %s", error->message);
}
else
{
//g_print("Plugins loaded \n");
GList *sources = grl_plugin_registry_get_sources(registry, TRUE);
g_print("Number of sources = %d \n", g_list_length(sources));
}
GrlConfig *config = grl_config_new ("grl-tracker", NULL);
grl_config_set_boolean (config, "browse-filesystem", TRUE);
grl_plugin_registry_add_config (registry, config, NULL);
config = grl_config_new ("grl-tracker", NULL);
grl_config_set_boolean (config, "per-device-source", TRUE);
grl_plugin_registry_add_config (registry, config, NULL);
}
gint main (gint argc, gchar **argv)
{
GMainLoop *loop;
grl_init (&argc, &argv);
load_plugins ();
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]