Index: fm-icon-view.c
===================================================================
--- fm-icon-view.c	(revision 13303)
+++ fm-icon-view.c	(working copy)
@@ -24,6 +24,7 @@
 
 #include <config.h>
 #include "fm-icon-view.h"
+#include "totem-mime-types.h"
 
 #include "fm-actions.h"
 #include "fm-icon-container.h"
@@ -80,7 +81,6 @@
 #include <unistd.h>
 #include <esd.h>
 
-#define USE_OLD_AUDIO_PREVIEW 1
 #define READ_CHUNK_SIZE 16384
 
 #define POPUP_PATH_ICON_APPEARANCE		"/selection/Icon Appearance Items"
@@ -167,9 +167,7 @@
 static int preview_sound_auto_value;
 static gboolean gnome_esd_enabled_auto_value;
 
-#if USE_OLD_AUDIO_PREVIEW
 static pid_t audio_preview_pid = 0;
-#endif
 
 static void                 fm_icon_view_set_directory_sort_by        (FMIconView           *icon_view,
 								       NautilusFile         *file,
@@ -1752,55 +1750,28 @@
 static gboolean
 play_file (gpointer callback_data)
 {
-#if USE_OLD_AUDIO_PREVIEW	
 	NautilusFile *file;
 	FMIconView *icon_view;
 	FILE *sound_process;
 	char *file_uri;
-	char *suffix;
-	char *mime_type;
 	const char *command_str;
-	gboolean is_mp3;
-	gboolean is_ogg;
 	pid_t mp3_pid;
-	
+
 	GnomeVFSResult result;
 	GnomeVFSHandle *handle;
 	char *buffer;
-	const char *audio_device = NULL;
 	GnomeVFSFileSize bytes_read;
 
-	audio_device = g_getenv ("AUDIODEV");
 	icon_view = FM_ICON_VIEW (callback_data);
-	
+
 	file = icon_view->details->audio_preview_file;
 	file_uri = nautilus_file_get_uri (file);
-	mime_type = nautilus_file_get_mime_type (file);
-	is_mp3 = eel_strcasecmp (mime_type, "audio/mpeg") == 0;
-	is_ogg = eel_strcasecmp (mime_type, "application/ogg") == 0 ||
-                eel_strcasecmp (mime_type, "application/x-ogg") == 0;
-	
+
 	mp3_pid = fork ();
 	if (mp3_pid == (pid_t) 0) {
 		/* Set the group (session) id to this process for future killing. */
 		setsid();
-		if (is_mp3) {
-			command_str = "mpg123 -y -q -";
-		} else if (is_ogg) {
-			command_str = "ogg123 -q -";
-		} else {
-			suffix = strrchr(file_uri, '.');
-			if (suffix == NULL) {
-				suffix = "wav";
-			} else {
-				suffix += 1; /* skip the period */
-			}
-			if (audio_device) {
-				command_str = g_strdup_printf("play -d %s -t %s -", audio_device, suffix);
-			} else {
-				command_str = g_strdup_printf("play -t %s -", suffix);
-			}
-		}
+		command_str = "totem-audio-preview";
 
 		/* read the file with gnome-vfs, feeding it to the sound player's standard input */
 		/* First, open the file. */
@@ -1808,17 +1779,17 @@
 		if (result != GNOME_VFS_OK) {
 			_exit (0);
 		}
-			
+
 		/* since the uri could be local or remote, we launch the sound player with popen and feed it
 		 * the data by fetching it with gnome_vfs
 		 */
 		sound_process = popen(command_str, "w");
 		if (sound_process == 0) {
 			/* Close the file. */
-			result = gnome_vfs_close (handle);			
+			result = gnome_vfs_close (handle);
 			_exit (0);
 		}
-			
+
 		/* allocate a buffer. */
 		buffer = g_malloc(READ_CHUNK_SIZE);
 			
@@ -1838,7 +1809,7 @@
 		} while (result == GNOME_VFS_OK);
 
 		/* Close the file. */
-		result = gnome_vfs_close (handle);			
+		result = gnome_vfs_close (handle);
 		g_free(buffer);
 		pclose(sound_process);
 		_exit (0);
@@ -1849,35 +1820,10 @@
 		}
 		audio_preview_pid = mp3_pid;
 	}
-		
-	g_free (file_uri);
-	g_free (mime_type);
 
-	icon_view->details->audio_preview_timeout = 0;
-#else
-	char *file_path, *file_uri, *mime_type;
-	gboolean is_mp3;
-	FMIconView *icon_view;
-	
-	icon_view = FM_ICON_VIEW (callback_data);
-		
-	file_uri = nautilus_file_get_uri (icon_view->details->audio_preview_file);
-	file_path = gnome_vfs_get_local_path_from_uri (file_uri);
-	mime_type = nautilus_file_get_mime_type (icon_view->details->audio_preview_file);
-
-	is_mp3 = eel_strcasecmp (mime_type, "audio/mpeg") == 0;
-
-	if (file_path != NULL && !is_mp3) {
-		icon_view->details->audio_player_data = nautilus_audio_player_play (file_path);
-	}
-	
 	g_free (file_uri);
-	g_free (file_path);	
-	g_free (mime_type);
 
 	icon_view->details->audio_preview_timeout = 0;
-	icon_view->details->audio_preview_file = NULL;
-#endif
 	return FALSE;
 }
 
@@ -1893,19 +1839,12 @@
 preview_audio (FMIconView *icon_view, NautilusFile *file, gboolean start_flag)
 {		
 	/* Stop current audio playback */
-#if USE_OLD_AUDIO_PREVIEW
 	if (audio_preview_pid > 0) {
 		kill (-audio_preview_pid, SIGTERM);
 		waitpid (audio_preview_pid, NULL, 0);
 		audio_preview_pid = 0;
 	}
-#else
-	if (icon_view->details->audio_player_data != NULL) {
-		nautilus_audio_player_stop (icon_view->details->audio_player_data);
-		g_free (icon_view->details->audio_player_data);
-		icon_view->details->audio_player_data = NULL;
-	}
-#endif
+
 	if (icon_view->details->audio_preview_timeout != 0) {
 		g_source_remove (icon_view->details->audio_preview_timeout);
 		icon_view->details->audio_preview_timeout = 0;
@@ -1913,16 +1852,30 @@
 			
 	if (start_flag) {
 		icon_view->details->audio_preview_file = file;
-#if USE_OLD_AUDIO_PREVIEW			
 		icon_view->details->audio_preview_timeout = g_timeout_add (1000, play_file, icon_view);
-#else
-		/* FIXME: Need to kill the existing timeout if there is one? */
-		icon_view->details->audio_preview_timeout = g_timeout_add (1000, play_file, icon_view);
-#endif
 	}
 }
 
 static gboolean
+sound_preview_type_supported (NautilusFile *file)
+{
+	char *mime_type;
+	guint i;
+
+	mime_type = nautilus_file_get_mime_type (file);
+	if (mime_type == NULL)
+		return FALSE;
+	for (i = 0; i < G_N_ELEMENTS (audio_mime_types); i++) {
+		if (strcmp (mime_type, audio_mime_types[i]) == 0) {
+			g_free (mime_type);
+			return TRUE;
+		}
+	}
+
+	return FALSE;
+}
+
+static gboolean
 should_preview_sound (NautilusFile *file)
 {
 	char *uri;
@@ -1943,11 +1896,11 @@
 	if (preview_sound_auto_value == NAUTILUS_SPEED_TRADEOFF_NEVER) {
 		return FALSE;
 	}
-		
+
 	if (preview_sound_auto_value == NAUTILUS_SPEED_TRADEOFF_ALWAYS) {
 		return TRUE;
 	}
-	
+
 	return nautilus_file_is_local (file);
 }
 
@@ -1956,12 +1909,10 @@
 {
 	int open_result;
 
-#if USE_OLD_AUDIO_PREVIEW			
 	/* first see if there's already one in progress; if so, return true */
 	if (audio_preview_pid > 0) {
 		return TRUE;
 	}
-#endif
 
 	/* Now check and see if system has audio out capabilites */
         open_result = esd_open_sound (NULL);
@@ -1981,25 +1932,17 @@
 				 FMIconView *icon_view)
 {
 	int result;
-	char *mime_type, *file_name, *message;
+	char *file_name, *message;
 		
 	result = 0;
 	
 	/* preview files based on the mime_type. */
 	/* at first, we just handle sounds */
 	if (should_preview_sound (file)) {
-		mime_type = nautilus_file_get_mime_type (file);
-
-		if ((eel_istr_has_prefix (mime_type, "audio/")
-		     || eel_istr_has_prefix (mime_type, "application/ogg")
-		     || eel_istr_has_prefix (mime_type, "application/x-ogg"))
-		    && eel_strcasecmp (mime_type, "audio/x-pn-realaudio") != 0
-		    && eel_strcasecmp (mime_type, "audio/x-mpegurl") != 0
-		    && can_play_sound ()) {
+		if (sound_preview_type_supported (file) && can_play_sound ()) {
 			result = 1;
 			preview_audio (icon_view, file, start_flag);
-		}	
-		g_free (mime_type);
+		}
 	}
 	
 	/* Display file name in status area at low zoom levels, since
Index: totem-mime-types.h
===================================================================
--- totem-mime-types.h	(revision 0)
+++ totem-mime-types.h	(revision 0)
@@ -0,0 +1,187 @@
+/* generated with mime-types-include.sh, don't edit */
+char *mime_types[] = {
+"application/ogg",
+"application/ram",
+"application/sdp",
+"application/smil",
+"application/vnd.rn-realmedia",
+"application/x-extension-m4a",
+"application/x-extension-mp4",
+"application/x-flac",
+"application/x-flash-video",
+"application/x-matroska",
+"application/x-netshow-channel",
+"application/x-ogg",
+"application/x-quicktime-media-link",
+"application/x-quicktimeplayer",
+"application/x-shorten",
+"application/x-smil",
+"application/xspf+xml",
+"audio/3gpp",
+"audio/ac3",
+"audio/AMR",
+"audio/AMR-WB",
+"audio/basic",
+"audio/mp4",
+"audio/mpeg",
+"audio/mpegurl",
+"audio/ogg",
+"audio/vnd.rn-realaudio",
+"audio/x-ape",
+"audio/x-flac",
+"audio/x-it",
+"audio/x-m4a",
+"audio/x-matroska",
+"audio/x-mod",
+"audio/x-mp3",
+"audio/x-mpeg",
+"audio/x-mpegurl",
+"audio/x-ms-asf",
+"audio/x-ms-asx",
+"audio/x-ms-wax",
+"audio/x-ms-wma",
+"audio/x-musepack",
+"audio/x-pn-aiff",
+"audio/x-pn-au",
+"audio/x-pn-realaudio",
+"audio/x-pn-realaudio-plugin",
+"audio/x-pn-wav",
+"audio/x-pn-windows-acm",
+"audio/x-realaudio",
+"audio/x-real-audio",
+"audio/x-sbc",
+"audio/x-scpls",
+"audio/x-tta",
+"audio/x-wav",
+"audio/x-wav",
+"audio/x-wavpack",
+"audio/x-vorbis",
+"image/vnd.rn-realpix",
+"image/x-pict",
+"misc/ultravox",
+"text/google-video-pointer",
+"text/x-google-video-pointer",
+"video/3gpp",
+"video/dv",
+"video/fli",
+"video/flv",
+"video/mp4",
+"video/mp4v-es",
+"video/mpeg",
+"video/msvideo",
+"video/quicktime",
+"video/vivo",
+"video/vnd.divx",
+"video/vnd.rn-realvideo",
+"video/vnd.vivo",
+"video/x-anim",
+"video/x-avi",
+"video/x-flc",
+"video/x-fli",
+"video/x-flic",
+"video/x-m4v",
+"video/x-matroska",
+"video/x-mpeg",
+"video/x-ms-asf",
+"video/x-msvideo",
+"video/x-ms-wm",
+"video/x-ms-wmv",
+"video/x-ms-wmx",
+"video/x-ms-wvx",
+"video/x-nsv",
+"video/x-ogm+ogg",
+"video/x-theora+ogg",
+};
+char *audio_mime_types[] = {
+"audio/3gpp",
+"audio/ac3",
+"audio/AMR",
+"audio/AMR-WB",
+"audio/basic",
+"audio/mp4",
+"audio/mpeg",
+"audio/mpegurl",
+"audio/ogg",
+"audio/vnd.rn-realaudio",
+"audio/x-ape",
+"audio/x-flac",
+"audio/x-it",
+"audio/x-m4a",
+"audio/x-matroska",
+"audio/x-mod",
+"audio/x-mp3",
+"audio/x-mpeg",
+"audio/x-mpegurl",
+"audio/x-ms-asf",
+"audio/x-ms-asx",
+"audio/x-ms-wax",
+"audio/x-ms-wma",
+"audio/x-musepack",
+"audio/x-pn-aiff",
+"audio/x-pn-au",
+"audio/x-pn-wav",
+"audio/x-pn-windows-acm",
+"audio/x-realaudio",
+"audio/x-real-audio",
+"audio/x-sbc",
+"audio/x-scpls",
+"audio/x-tta",
+"audio/x-wav",
+"audio/x-wav",
+"audio/x-wavpack",
+"audio/x-vorbis",
+};
+char *video_mime_types[] = {
+"application/ogg",
+"application/ram",
+"application/sdp",
+"application/smil",
+"application/vnd.rn-realmedia",
+"application/x-extension-m4a",
+"application/x-extension-mp4",
+"application/x-flash-video",
+"application/x-matroska",
+"application/x-netshow-channel",
+"application/x-ogg",
+"application/x-quicktime-media-link",
+"application/x-quicktimeplayer",
+"application/x-shorten",
+"application/x-smil",
+"application/xspf+xml",
+"image/vnd.rn-realpix",
+"image/x-pict",
+"misc/ultravox",
+"text/google-video-pointer",
+"text/x-google-video-pointer",
+"video/3gpp",
+"video/dv",
+"video/fli",
+"video/flv",
+"video/mp4",
+"video/mp4v-es",
+"video/mpeg",
+"video/msvideo",
+"video/quicktime",
+"video/vivo",
+"video/vnd.divx",
+"video/vnd.rn-realvideo",
+"video/vnd.vivo",
+"video/x-anim",
+"video/x-avi",
+"video/x-flc",
+"video/x-fli",
+"video/x-flic",
+"video/x-m4v",
+"video/x-matroska",
+"video/x-mpeg",
+"video/x-ms-asf",
+"video/x-msvideo",
+"video/x-ms-wm",
+"video/x-ms-wmv",
+"video/x-ms-wmx",
+"video/x-ms-wvx",
+"video/x-nsv",
+"video/x-ogm+ogg",
+"video/x-theora+ogg",
+"audio/x-pn-realaudio",
+};
