[Rhythmbox-devel] Podcast remember playtime patch
- From: "Marc E." <elcomandante sbcglobal net>
- To: Rhythmbox <rhythmbox-devel gnome org>
- Subject: [Rhythmbox-devel] Podcast remember playtime patch
- Date: Sat, 28 Jan 2006 02:05:56 -0800
I've attached an updated patch to remember the location of the playtime
on podcats.
It is based on James Livingston's original patch
(http://mail.gnome.org/archives/rhythmbox-devel/2005-October/msg00130.html), updated to latest GNOME (anon) CVS.
This is my first time attempting to do a patch (did it with cvs diff -u
> out.patch).
*It might need work*
Hope it gets commited, and keep up the good work
? podcast.patch
Index: rhythmdb/rhythmdb-tree.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/rhythmdb/rhythmdb-tree.c,v
retrieving revision 1.88
diff -u -r1.88 rhythmdb-tree.c
--- rhythmdb/rhythmdb-tree.c 16 Jan 2006 05:32:51 -0000 1.88
+++ rhythmdb/rhythmdb-tree.c 28 Jan 2006 10:04:09 -0000
@@ -453,6 +453,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:
@@ -806,7 +809,11 @@
case RHYTHMDB_PROP_POST_TIME:
if (entry->podcast)
save_entry_ulong (ctx, elt_name, entry->podcast->post_time, FALSE);
- break;
+ break;
+ case RHYTHMDB_PROP_PLAYBACK_POS:
+ if (entry->podcast)
+ save_entry_ulong (ctx, elt_name, entry->podcast->playback_pos, FALSE);
+ break;
case RHYTHMDB_PROP_TITLE_SORT_KEY:
case RHYTHMDB_PROP_GENRE_SORT_KEY:
case RHYTHMDB_PROP_ARTIST_SORT_KEY:
Index: rhythmdb/rhythmdb.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/rhythmdb/rhythmdb.c,v
retrieving revision 1.161
diff -u -r1.161 rhythmdb.c
--- rhythmdb/rhythmdb.c 23 Jan 2006 11:49:34 -0000 1.161
+++ rhythmdb/rhythmdb.c 28 Jan 2006 10:04:15 -0000
@@ -2550,6 +2550,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;
@@ -3504,6 +3507,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.65
diff -u -r1.65 rhythmdb.h
--- rhythmdb/rhythmdb.h 16 Jan 2006 13:45:45 -0000 1.65
+++ rhythmdb/rhythmdb.h 28 Jan 2006 10:04:15 -0000
@@ -117,7 +117,7 @@
RHYTHMDB_PROP_COPYRIGHT,
RHYTHMDB_PROP_IMAGE,
RHYTHMDB_PROP_POST_TIME,
-
+ RHYTHMDB_PROP_PLAYBACK_POS,
RHYTHMDB_NUM_PROPERTIES
} RhythmDBPropType;
@@ -155,6 +155,7 @@
102: wait
103: pause */
gulong post_time;
+ gulong playback_pos; /* saved playback position */
} RhythmDBPodcastFields;
@@ -368,6 +369,11 @@
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:
if (entry->podcast)
return entry->podcast->status;
Index: shell/rb-shell-player.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/shell/rb-shell-player.c,v
retrieving revision 1.203
diff -u -r1.203 rb-shell-player.c
--- shell/rb-shell-player.c 26 Jan 2006 21:11:39 -0000 1.203
+++ shell/rb-shell-player.c 28 Jan 2006 10:04:17 -0000
@@ -140,6 +140,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);
static void gconf_song_position_slider_visibility_changed (GConfClient *client,guint cnxn_id,
GConfEntry *entry, RBShellPlayer *player);
static void rb_shell_player_playing_changed_cb (RBShellPlayer *player,
@@ -609,6 +610,7 @@
g_return_if_fail (player->priv != NULL);
+ rb_shell_player_entry_changing (player);
eel_gconf_notification_remove (player->priv->gconf_play_order_id);
eel_gconf_set_float (CONF_STATE_VOLUME, player->priv->volume);
@@ -1020,7 +1022,12 @@
rb_shell_player_sync_replaygain (player, entry);
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_debug ("Success!");
/* clear error on successful playback */
g_free (entry->playback_error);
@@ -1484,6 +1491,7 @@
/* selection takes precedence over first item in play order */
if (entry == NULL) {
songs = rb_source_get_entry_view (player->priv->source);
+ rb_shell_player_entry_changing (player);
GList* selection = rb_entry_view_get_selected_entries (songs);
if (selection != NULL) {
rb_debug ("choosing first selected entry");
@@ -1932,6 +1940,7 @@
RBSource *source,
gboolean sync_entry_view)
{
+ rb_shell_player_entry_changing (player);
player->priv->source = source;
player->priv->current_playing_source = source;
@@ -2427,6 +2436,32 @@
return TRUE;
}
+
+static void
+rb_shell_player_entry_changing (RBShellPlayer *player)
+{
+ /* Not sure about this */
+ RhythmDBEntry *old_entry;
+ old_entry = rb_shell_player_get_playing_entry (player);
+
+ 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);
+ g_value_unset (&val);
+ }
+ }
+ }
#ifdef HAVE_MMKEYS
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]