Index: audio-inline.c
===================================================================
--- audio-inline.c	(revision 33316)
+++ audio-inline.c	(working copy)
@@ -86,108 +86,42 @@
 	}
 }
 
-static GstElement *
-org_gnome_audio_inline_gst_mpeg_thread (GstElement *filesrc)
+static char *
+create_full_path (const char *path)
 {
-	GstElement *thread, *decoder, *audiosink;
-
-	/* create a new thread to hold the elements */
-	thread = gst_thread_new ("org-gnome-audio-inline-mpeg-thread");
-
-	/* now it's time to get the decoder */
-	decoder = gst_element_factory_make ("mad", "decoder");
-                                
-	/* and an audio sink */
-	audiosink = gst_element_factory_make ("osssink", "play_audio");
-                                    
-	/* add objects to the main pipeline */
-	gst_bin_add_many (GST_BIN (thread), filesrc, decoder, audiosink, NULL);
-                                        
-	/* link src to sink */
-	gst_element_link_many (filesrc, decoder, audiosink, NULL);
-
-	return thread;
+	char *retval;
+	retval = g_strdup_printf ("file://%s", path);
+	return retval;
 }
 
 static GstElement *
-org_gnome_audio_inline_gst_ogg_thread (GstElement *filesrc)
+org_gnome_audio_inline_gst_thread (GstElement *playbin)
 {
-	GstElement *thread, *demuxer, *decoder, *converter, *audiosink;
+	GstElement *thread, *audiosink;
 
 	/* create a new thread to hold the elements */
-	thread = gst_thread_new ("org-gnome-audio-inline-mpeg-thread");
+	thread = gst_thread_new ("org-gnome-audio-inline-thread");
 
-	/* create an ogg demuxer */
-	demuxer = gst_element_factory_make ("oggdemux", "demuxer");
-	g_assert (demuxer != NULL);
-                                                                            
-	/* create a vorbis decoder */
-	decoder = gst_element_factory_make ("vorbisdec", "decoder");
-	g_assert (decoder != NULL);
-                                                                                  
-	/* create an audio converter */
-	converter = gst_element_factory_make ("audioconvert", "converter");
-	g_assert (decoder != NULL);
-                                                                                        
-	/* and an audio sink */
-	audiosink = gst_element_factory_make ("osssink", "play_audio");
-	g_assert (audiosink != NULL);
-                                                                                              
-	/* add objects to the thread */
-	gst_bin_add_many (GST_BIN (thread), filesrc, demuxer, decoder, converter, audiosink, NULL);
-
-	/* link them in the logical order */
-	gst_element_link_many (filesrc, demuxer, decoder, converter, audiosink, NULL);
-
-	return thread;
-}
-
-static GstElement *
-org_gnome_audio_inline_gst_flac_thread (GstElement *filesrc)
-{
-	GstElement *thread, *decoder, *audiosink;
-
-	/* create a new thread to hold the elements */
-	thread = gst_thread_new ("org-gnome-audio-inline-flac-thread");
-
-	/* now it's time to get the decoder */
-	decoder = gst_element_factory_make ("flacdec", "decoder");
-                                
-	/* and an audio sink */
-	audiosink = gst_element_factory_make ("osssink", "play_audio");
+	/* now it's time to get the audio sink */
+	audiosink = gst_element_factory_make ("gconfaudiosink", "play_audio");
+	if (audiosink == NULL) {
+		audiosink = gst_element_factory_make ("autoaudiosink", "play_audio");
+	}
+	if (audiosink == NULL) {
+		gst_object_unref (GST_OBJECT (thread));
+		return NULL;
+	}
                                     
 	/* add objects to the main pipeline */
-	gst_bin_add_many (GST_BIN (thread), filesrc, decoder, audiosink, NULL);
+	gst_bin_add_many (GST_BIN (thread), playbin, audiosink, NULL);
                                         
 	/* link src to sink */
-	gst_element_link_many (filesrc, decoder, audiosink, NULL);
+	gst_element_link_many (playbin, audiosink, NULL);
+	}
 
 	return thread;
 }
 
-static GstElement *
-org_gnome_audio_inline_gst_mod_thread (GstElement *filesrc)
-{
-	GstElement *thread, *decoder, *audiosink;
-
-	/* create a new thread to hold the elements */
-	thread = gst_thread_new ("org-gnome-audio-inline-flac-thread");
-
-	/* now it's time to get the decoder */
-	decoder = gst_element_factory_make ("mikmod", "decoder");
-                                
-	/* and an audio sink */
-	audiosink = gst_element_factory_make ("osssink", "play_audio");
-                                    
-	/* add objects to the main pipeline */
-	gst_bin_add_many (GST_BIN (thread), filesrc, decoder, audiosink, NULL);
-                                        
-	/* link src to sink */
-	gst_element_link_many (filesrc, decoder, audiosink, NULL);
-
-	return thread;
-}
-
 static void
 org_gnome_audio_inline_play_clicked (GtkWidget *button, EMFormatHTMLPObject *pobject)
 {
@@ -215,29 +149,15 @@
 
 		if (gst_init_check (&argc, (char ***) &argv)) {
 			CamelContentType *type;
-			GstElement *filesrc;
+			GstElement *playbin;
 
 			/* create a disk reader */
-			filesrc = gst_element_factory_make ("filesrc", "disk_source");
-			g_object_set (G_OBJECT (filesrc), "location", po->filename, NULL);
-
-			type = camel_mime_part_get_content_type (po->part);
-			if (type) {
-				if (!g_ascii_strcasecmp (type->type, "audio")) {
-					if (!g_ascii_strcasecmp (type->subtype, "mpeg") || !g_ascii_strcasecmp (type->subtype, "x-mpeg")
-					    || !g_ascii_strcasecmp (type->subtype, "mpeg3") || !g_ascii_strcasecmp (type->subtype, "x-mpeg3")
-					    || !g_ascii_strcasecmp (type->subtype, "mp3") || !g_ascii_strcasecmp (type->subtype, "x-mp3")) {
-						po->thread = org_gnome_audio_inline_gst_mpeg_thread (filesrc);
-					} else if (!g_ascii_strcasecmp (type->subtype, "flac") || !g_ascii_strcasecmp (type->subtype, "x-flac")) {
-						po->thread = org_gnome_audio_inline_gst_flac_thread (filesrc);
-					} else if (!g_ascii_strcasecmp (type->subtype, "mod") || !g_ascii_strcasecmp (type->subtype, "x-mod")) {
-						po->thread = org_gnome_audio_inline_gst_mod_thread (filesrc);
-					}
-				} else if (!g_ascii_strcasecmp (type->type, "application")) {
-					if (!g_ascii_strcasecmp (type->subtype, "ogg") || !g_ascii_strcasecmp (type->subtype, "x-ogg")) {
-						po->thread = org_gnome_audio_inline_gst_ogg_thread (filesrc);
-					}
-				}
+			playbin = gst_element_factory_make ("playbin", "playbin");
+			if (playbin == NULL) {
+				d(printf ("Failed to create gst_element_factory playbin; check your installation\n"));
+			} else {	       
+				g_object_set (G_OBJECT (playbin), "uri", create_full_path(po->filename), NULL);
+				po->thread = org_gnome_audio_inline_gst_thread (playbin);
 			}
 		}
 	}
