Re: [Rhythmbox-devel] New Podcast path



That is great :). The duration status feature is really amazing, and useful.

Another thing I noticed, wouldn´t it be better to rename the sidebar´s "Podcast" item to "Podcasts"?

Also are the information columns configurable?, like iTunes (yes, I like it :-P), It would be really nice if you could change the columns´ position around.

Great job on the patch, I look forward to seeing it on the next release.

James Livingston escribió:

On Thu, 2005-10-20 at 15:56 -0700, Marc E. wrote:


Does it have the same functionality as iTunes, like if you stop playing it, and start playing something else, then you play the old one, it picks up at the time you left it?



Attached is a first attempt at doing this. There are a couple of things that need improvement:

* It doesn't save the position when quitting, you have to stop or change
what's playing first.
* Occasionally the seek bar has the wrong duration
* This should really be gone with the "song changed" signal, and a new
"pre-change" signal (for doing things with the track that is ending).


Cheers,

James "Doc" Livingston


------------------------------------------------------------------------

Index: rhythmdb/rhythmdb-tree.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/rhythmdb/rhythmdb-tree.c,v
retrieving revision 1.75
diff -u -u -r1.75 rhythmdb-tree.c
--- rhythmdb/rhythmdb-tree.c	20 Oct 2005 16:42:16 -0000	1.75
+++ rhythmdb/rhythmdb-tree.c	22 Oct 2005 04:08:38 -0000
@@ -420,6 +420,9 @@
		case RHYTHMDB_PROP_POST_TIME:			
			ctx->entry->podcast->post_time = parse_ulong (ctx->buf->str);
			break;
+		case RHYTHMDB_PROP_PLAYBACK_POS:
+			ctx->entry->podcast->playback_pos = parse_ulong (ctx->buf->str);
+			break;
		case RHYTHMDB_PROP_TITLE_SORT_KEY:
		case RHYTHMDB_PROP_GENRE_SORT_KEY:
		case RHYTHMDB_PROP_ARTIST_SORT_KEY:
@@ -766,6 +769,10 @@
		case RHYTHMDB_PROP_POST_TIME:
			if (entry->podcast)
				save_entry_ulong (ctx, elt_name, entry->podcast->post_time);
+			break;			
+		case RHYTHMDB_PROP_PLAYBACK_POS:
+			if (entry->podcast)
+				save_entry_ulong (ctx, elt_name, entry->podcast->playback_pos);
			break;			
		case RHYTHMDB_PROP_TITLE_SORT_KEY:
		case RHYTHMDB_PROP_GENRE_SORT_KEY:
Index: rhythmdb/rhythmdb.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/rhythmdb/rhythmdb.c,v
retrieving revision 1.120
diff -u -u -r1.120 rhythmdb.c
--- rhythmdb/rhythmdb.c	20 Oct 2005 16:42:16 -0000	1.120
+++ rhythmdb/rhythmdb.c	22 Oct 2005 04:08:44 -0000
@@ -2149,6 +2149,9 @@
	case RHYTHMDB_PROP_POST_TIME:
		entry->podcast->post_time = g_value_get_ulong (value);
		break;	
+	case RHYTHMDB_PROP_PLAYBACK_POS:
+		entry->podcast->playback_pos = g_value_get_ulong (value);
+		break;	
	case RHYTHMDB_NUM_PROPERTIES:
		g_assert_not_reached ();
		break;
@@ -2829,6 +2832,7 @@
			ENUM_ENTRY (RHYTHMDB_PROP_COPYRIGHT, "Podcast copyright (gchararray) [copyright]"),
			ENUM_ENTRY (RHYTHMDB_PROP_IMAGE, "Podcast image(gchararray) [image]"),
			ENUM_ENTRY (RHYTHMDB_PROP_POST_TIME, "Podcast time of post (gulong) [post-time]"),
+			ENUM_ENTRY (RHYTHMDB_PROP_PLAYBACK_POS, "Saved playback position (gulong) [playback-position]"),
			{ 0, 0, 0 }
		};
		g_assert ((sizeof (values) / sizeof (values[0]) - 1) == RHYTHMDB_NUM_PROPERTIES);
Index: rhythmdb/rhythmdb.h
===================================================================
RCS file: /cvs/gnome/rhythmbox/rhythmdb/rhythmdb.h,v
retrieving revision 1.52
diff -u -u -r1.52 rhythmdb.h
--- rhythmdb/rhythmdb.h	21 Oct 2005 03:05:44 -0000	1.52
+++ rhythmdb/rhythmdb.h	22 Oct 2005 04:08:48 -0000
@@ -112,6 +112,7 @@
	RHYTHMDB_PROP_COPYRIGHT,
	RHYTHMDB_PROP_IMAGE,
	RHYTHMDB_PROP_POST_TIME,
+	RHYTHMDB_PROP_PLAYBACK_POS,
	
	RHYTHMDB_NUM_PROPERTIES
} RhythmDBPropType;
@@ -138,8 +139,9 @@
	RBRefString *lang;
	RBRefString *copyright;
	RBRefString *image;
-	gulong status;   //0-99: downloading; 100: Conplete; 101: Error; 102: wait; 103: pause;
+	gulong status;   /*0-99: downloading; 100: Conplete; 101: Error; 102: wait; 103: pause;*/
	gulong post_time;
+	gulong playback_pos; /* saved playback position */
} RhythmDBPodcastFields;


@@ -343,6 +345,11 @@ case RHYTHMDB_PROP_POST_TIME: if (entry->podcast) return entry->podcast->post_time; + else + return 0; + case RHYTHMDB_PROP_PLAYBACK_POS: + if (entry->podcast) + return entry->podcast->playback_pos; else return 0; case RHYTHMDB_PROP_STATUS: Index: shell/rb-shell-player.c =================================================================== RCS file: /cvs/gnome/rhythmbox/shell/rb-shell-player.c,v retrieving revision 1.177 diff -u -u -r1.177 rb-shell-player.c --- shell/rb-shell-player.c 22 Oct 2005 02:13:04 -0000 1.177 +++ shell/rb-shell-player.c 22 Oct 2005 04:08:53 -0000 @@ -162,6 +162,7 @@

static void gconf_play_order_changed (GConfClient *client,guint cnxn_id,
				      GConfEntry *entry, RBShellPlayer *player);
+static void rb_shell_player_entry_changing (RBShellPlayer *player);

#ifdef HAVE_MMKEYS
static void grab_mmkey (int key_code, GdkWindow *root);
@@ -738,6 +739,7 @@

	g_return_if_fail (player->priv != NULL);

+	rb_shell_player_entry_changing (player);
	if (player->priv->playing_attempt_entry)
		rhythmdb_entry_unref (player->priv->db, player->priv->playing_attempt_entry);

@@ -1119,6 +1121,8 @@
	
	songs = rb_source_get_entry_view (player->priv->source);

+	rb_shell_player_entry_changing (player);
+	
	if (player->priv->playing_attempt_entry)
		rhythmdb_entry_unref (player->priv->db, player->priv->playing_attempt_entry);
	rhythmdb_entry_ref (player->priv->db, entry);
@@ -1129,6 +1133,12 @@
	if (!rb_shell_player_play (player, &tmp_error))
		goto lose;

+	if (entry && rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_TYPE) == RHYTHMDB_ENTRY_TYPE_PODCAST_POST) {
+		gulong save_time = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_PLAYBACK_POS);
+		rb_debug ("restoring podcast playback position %d", save_time);
+		rb_player_set_time (player->priv->mmplayer, save_time);
+	}
+
	rb_entry_view_set_playing_entry (songs, entry);

	rb_debug ("Success!");
@@ -1957,8 +1967,8 @@
						      player);
	}
	
+	rb_shell_player_entry_changing (player);
	player->priv->source = source;
-
	if (player->priv->playing_attempt_entry)
		rhythmdb_entry_unref (player->priv->db, player->priv->playing_attempt_entry);
	player->priv->playing_attempt_entry = NULL;
@@ -2395,6 +2405,29 @@
	}

	return TRUE;
+}
+
+static void
+rb_shell_player_entry_changing (RBShellPlayer *player)
+{
+	RhythmDBEntry *old_entry = player->priv->playing_attempt_entry;
+	
+	if (old_entry) {
+		if (rhythmdb_entry_get_ulong (old_entry, RHYTHMDB_PROP_TYPE) == RHYTHMDB_ENTRY_TYPE_PODCAST_POST) {
+			gulong cur_time = rb_player_get_time (player->priv->mmplayer);
+			gulong duration = rhythmdb_entry_get_ulong (old_entry, RHYTHMDB_PROP_DURATION);
+			GValue val = {0,};
+		
+			/* save the position, if not withing 5 seconds of either end */
+			if ((cur_time < 5) && (cur_time > duration - 5))
+				cur_time = 0;
+		
+			rb_debug ("saving podcast playback position %d", cur_time);
+			g_value_init (&val, G_TYPE_ULONG);
+			g_value_set_ulong (&val, cur_time);
+			rhythmdb_entry_set (player->priv->db, old_entry, RHYTHMDB_PROP_PLAYBACK_POS, &val);
+		}
+	}
}

#ifdef HAVE_MMKEYS




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]