Extract the mime-type using GIO.
authorZeeshan Ali (Khattak) <zeeshanak@src.gnome.org>
Tue, 5 Aug 2008 15:49:24 +0000 (15:49 +0000)
committerZeeshan Ali (Khattak) <zeeshanak@src.gnome.org>
Tue, 5 Aug 2008 15:49:24 +0000 (15:49 +0000)
svn path=/trunk/; revision=224

ChangeLog
src/gupnp-metadata-extractor.vala

index fb5b7b0..8123c48 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 
 2008-06-27  Zeeshan Ali Khattak  <zeenix@gmail.com>
 
+       * src/gupnp-metadata-extractor.vala:
+
+       Extract the mime-type using GIO.
+
+2008-06-27  Zeeshan Ali Khattak  <zeenix@gmail.com>
+
        * configure.ac:
        * src/Makefile.am:
 
index 3c43a2b..377a3c6 100644 (file)
@@ -54,6 +54,7 @@ public class GUPnP.MetadataExtractor: GLib.Object {
             this.playbin.uri = value;
 
             if (this.playbin.uri != null) {
+                extract_mime ();
                 /* Start the extaction when we get a new URI */
                 this.playbin.set_state (State.PAUSED);
             }
@@ -93,6 +94,34 @@ public class GUPnP.MetadataExtractor: GLib.Object {
         }
     }
 
+    private void extract_mime () {
+        File file = File.new_for_uri (this.uri);
+
+        weak FileInfo file_info;
+
+        try {
+            file_info = file.query_info (FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+                                         FileQueryInfoFlags.NONE,
+                                         null);
+        } catch (Error error) {
+            critical ("Failed to query content type for '%s'\n", this.uri);
+
+            return;
+        }
+
+        weak string content_type = file_info.get_content_type ();
+        weak string mime = g_content_type_get_mime_type (content_type);
+        if (mime != null) {
+            GLib.Value value;
+
+            value.init (typeof (string));
+            value.set_string (mime);
+
+            /* signal the availability of new tag */
+            this.metadata_available (this.playbin.uri, "mime-type", ref value);
+        }
+    }
+
     private void tag_cb (Gst.Bus     bus,
                          Gst.Message message) {
         TagList tag_list;