[Xfce4-commits] <parole:0.2.2> Use taglibc if available to get the media length

Ali Abdallah noreply at xfce.org
Thu Dec 16 11:20:01 CET 2010


Updating branch refs/heads/0.2.2
         to 88c21ec6ca28e8cc7405d62270b3c100732c2997 (commit)
       from 2577312bc433e1112a97c0270bd7a936c52f6414 (commit)

commit 88c21ec6ca28e8cc7405d62270b3c100732c2997
Author: Ali Abdallah <aliov at xfce.org>
Date:   Thu Dec 16 11:00:33 2010 +0100

    Use taglibc if available to get the media length

 gst/parole-gst.c       |    1 +
 src/parole-medialist.c |    1 +
 src/parole-utils.c     |   51 +++++++++++++++++++++++++++++++++++++++++++++++-
 src/parole-utils.h     |    1 +
 4 files changed, 53 insertions(+), 1 deletions(-)

diff --git a/gst/parole-gst.c b/gst/parole-gst.c
index 9f6ad9f..c8ff6bd 100644
--- a/gst/parole-gst.c
+++ b/gst/parole-gst.c
@@ -871,6 +871,7 @@ parole_gst_update_vis (ParoleGst *gst)
 
     gst->priv->update_vis = FALSE;
     g_free (vis_name);
+    gtk_widget_queue_draw (GTK_WIDGET (gst));
     TRACE ("end");
 }
 
diff --git a/src/parole-medialist.c b/src/parole-medialist.c
index 2981629..14f1018 100644
--- a/src/parole-medialist.c
+++ b/src/parole-medialist.c
@@ -215,6 +215,7 @@ parole_media_list_add (ParoleMediaList *list, ParoleFile *file, gboolean emit, g
 			&iter, 
 			NAME_COL, parole_file_get_display_name (file),
 			DATA_COL, file,
+			LENGTH_COL, parole_taglibc_get_media_length (file),
 			-1);
     
     if ( emit || select_row )
diff --git a/src/parole-utils.c b/src/parole-utils.c
index 7c9655e..3d09548 100644
--- a/src/parole-utils.c
+++ b/src/parole-utils.c
@@ -38,6 +38,10 @@
 #include <linux/cdrom.h>
 #endif
 
+#ifdef HAVE_TAGLIBC
+#include <taglib/tag_c.h>
+#endif
+
 #include <libxfce4util/libxfce4util.h>
 
 #include <parole/parole.h>
@@ -618,7 +622,13 @@ parole_set_widget_image_from_stock (GtkWidget *widget, gchar *stock_id)
     }
 }
 
-
+/**
+ * parole_format_media_length:
+ * 
+ * @total_seconds: lenght of the media file in seconds
+ * 
+ * Returns : formated string for the media lenght
+ **/
 gchar *parole_format_media_length (gint total_seconds)
 {
     gchar *timestring;
@@ -643,3 +653,42 @@ gchar *parole_format_media_length (gint total_seconds)
     
     return timestring;
 }
+
+/**
+ * parole_taglibc_get_media_length:
+ * 
+ * @ParoleFile: a ParoleFile
+ * 
+ * Returns: the length of the media only if the file is a local
+ * 	    media file.
+ **/
+gchar *parole_taglibc_get_media_length (ParoleFile *file)
+{
+    #ifdef HAVE_TAGLIBC
+    
+    TagLib_File *tag_file;
+    
+    if (g_str_has_prefix (parole_file_get_uri (file), "file:/"))
+    {
+	tag_file = taglib_file_new (parole_file_get_file_name (file));
+    
+	if ( tag_file )
+	{
+	    gint length = 0;
+	    const TagLib_AudioProperties *prop = taglib_file_audioproperties (tag_file);
+	    
+	    length = taglib_audioproperties_length (prop);
+	    
+	    taglib_file_free (tag_file);
+	    
+	    if (length != 0)
+		return parole_format_media_length (length);
+	}
+    }
+
+    #endif /* HAVE_TAGLIBC */
+    
+    return NULL;
+}
+
+
diff --git a/src/parole-utils.h b/src/parole-utils.h
index f2d49da..f5f4472 100644
--- a/src/parole-utils.h
+++ b/src/parole-utils.h
@@ -55,5 +55,6 @@ void		parole_set_widget_image_from_stock 	(GtkWidget *widget,
 
 gchar	       *parole_format_media_length		(gint total_seconds);
 
+gchar 	       *parole_taglibc_get_media_length 	(ParoleFile *file);
 
 #endif /* __PAROLE_UTILS_ */



More information about the Xfce4-commits mailing list