From: Julien M. <do...@us...> - 2003-02-28 13:33:00
|
CVS Root: /cvsroot/gstreamer Module: gst-player Changes by: dolphy Date: Fri Feb 28 2003 05:32:58 PST Log message: Improving playlist, fixed some bugs (removing current song, should play remaining ones) Moreover adding a whole bunch of files to the playlist should not crash the player anymore as it's not considered as a playlist change (for the playback purpose) Modified files: libs/gst/player : gstmediaplay.c gtk-playlist.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstmediaplay.c.diff?r1=1.99&r2=1.100 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gtk-playlist.c.diff?r1=1.4&r2=1.5 ====Begin Diffs==== Index: gstmediaplay.c =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstmediaplay.c,v retrieving revision 1.99 retrieving revision 1.100 diff -u -d -r1.99 -r1.100 --- gstmediaplay.c 12 Feb 2003 14:08:21 -0000 1.99 +++ gstmediaplay.c 28 Feb 2003 13:32:45 -0000 1.100 @@ -990,7 +990,7 @@ gst_media_play_set_state (mplay, GST_STATE_READY); - if (g_file_exists (location)) { + if (g_file_test (location,G_FILE_TEST_EXISTS)) { g_message ("location is a local file using filesrc"); datasrc = gst_element_factory_make ("filesrc", "source"); } Index: gtk-playlist.c =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gtk-playlist.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gtk-playlist.c 29 Jan 2003 14:49:41 -0000 1.4 +++ gtk-playlist.c 28 Feb 2003 13:32:45 -0000 1.5 @@ -518,7 +518,7 @@ /* The current item was removed from the playlist */ playlist->_priv->current = NULL; g_signal_emit (G_OBJECT (playlist), - gtk_playlist_table_signals[CURRENT_REMOVED], 0, + gtk_playlist_table_signals[CHANGED], 0, NULL); } else { if (ref != NULL) @@ -528,9 +528,6 @@ gtk_tree_row_reference_get_path (ref); gtk_tree_row_reference_free (ref); } - g_signal_emit (G_OBJECT (playlist), - gtk_playlist_table_signals[CHANGED], 0, - NULL); } } @@ -882,9 +879,9 @@ playlist->_priv->current = gtk_tree_model_get_path (playlist->_priv->model, &iter); - g_signal_emit (G_OBJECT (playlist), + /*g_signal_emit (G_OBJECT (playlist), gtk_playlist_table_signals[CHANGED], 0, - NULL); + NULL);*/ return TRUE; } @@ -899,6 +896,13 @@ if (eel_read_entire_file (mrl, &size, &contents) != GNOME_VFS_OK) return FALSE; + if (strstr (contents, "\n") == NULL) + { + retval = gtk_playlist_add_one_mrl (playlist, contents, NULL); + g_free (contents); + return retval; + } + lines = g_strsplit (contents, "\n", 0); g_free (contents); @@ -1092,6 +1096,18 @@ return retval; } +static gboolean +gtk_playlist_add_ra (GtkPlaylist *playlist, const char *mrl) +{ + /* How nice, same format as m3u it seems */ + return gtk_playlist_add_m3u (playlist, mrl); +} +#if 0 //FIXME +static gboolean +gtk_playlist_add_wmv (GtkPlaylist *playlist, const char *mrl) +{ +} +#endif gboolean gtk_playlist_add_mrl (GtkPlaylist *playlist, const char *mrl, const char *display_name) @@ -1112,6 +1128,9 @@ return gtk_playlist_add_pls (playlist, mrl); } else if (strcmp ("audio/x-ms-asx", mimetype) == 0) { return gtk_playlist_add_asx (playlist, mrl); + } else if (strcmp ("audio/x-real-audio", mimetype) == 0 + || strcmp ("audio/x-pn-realaudio", mimetype) == 0) { + return gtk_playlist_add_ra (playlist, mrl); } else if (strcmp ("x-directory/normal", mimetype) == 0) { //FIXME Load all the files in the dir ? } @@ -1395,18 +1414,30 @@ gchar * gtk_playlist_mrl_to_title (const gchar *mrl) { - char *filename_for_display, *filename, *unescaped; + char *filename_for_display, *with_suffix, *filename, *unescaped; filename = g_path_get_basename (mrl); unescaped = gnome_vfs_unescape_string_for_display (filename); g_free (filename); - filename_for_display = g_filename_to_utf8 (unescaped, + with_suffix = g_filename_to_utf8 (unescaped, -1, /* length */ NULL, /* bytes_read */ NULL, /* bytes_written */ NULL); /* error */ g_free (unescaped); + + if (strrchr (with_suffix, '.') + && strlen (strrchr (with_suffix, '.')) < 5) + { + filename_for_display = g_strndup (with_suffix, + strlen (with_suffix) + - strlen (strrchr (with_suffix, '.'))); + } else { + filename_for_display = g_strdup (with_suffix); + } + + g_free (with_suffix); return filename_for_display; } |