summaryrefslogtreecommitdiff
path: root/src/totem-playlist.c
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2019-02-16 20:12:43 +0100
committerBastien Nocera <hadess@hadess.net>2019-02-17 01:56:57 +0000
commit6029009e385ee3aa1380eeb82686a817e6ac88cf (patch)
treec5580c51ad752c4665fadb339521d88534c4e13d /src/totem-playlist.c
parent79548ddd8eb88bb760e23ad5427573a833fc0c10 (diff)
downloadtotem-6029009e385ee3aa1380eeb82686a817e6ac88cf.tar.gz
main: Save the starttime from the playlist parser
Diffstat (limited to 'src/totem-playlist.c')
-rw-r--r--src/totem-playlist.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/totem-playlist.c b/src/totem-playlist.c
index 01203e194..734d0435e 100644
--- a/src/totem-playlist.c
+++ b/src/totem-playlist.c
@@ -41,6 +41,7 @@ static gboolean totem_playlist_add_one_mrl (TotemPlaylist *playlist,
const char *display_name,
const char *content_type,
const char *subtitle_uri,
+ gint64 starttime,
gboolean playing);
typedef gboolean (*ClearComparisonFunc) (TotemPlaylist *playlist, GtkTreeIter *iter, gconstpointer data);
@@ -111,6 +112,7 @@ enum {
FILE_MONITOR_COL,
MOUNT_COL,
MIME_TYPE_COL,
+ STARTTIME_COL,
NUM_COLS
};
@@ -738,8 +740,8 @@ totem_playlist_entry_parsed (TotemPlParser *parser,
GHashTable *metadata,
TotemPlaylist *playlist)
{
- const char *title, *content_type, *subtitle_uri, *starttime;
- gint64 duration;
+ const char *title, *content_type, *subtitle_uri, *starttime_str;
+ gint64 duration, starttime;
gboolean playing;
/* We ignore 0-length items in playlists, they're usually just banners */
@@ -751,14 +753,14 @@ totem_playlist_entry_parsed (TotemPlParser *parser,
content_type = g_hash_table_lookup (metadata, TOTEM_PL_PARSER_FIELD_CONTENT_TYPE);
playing = parse_bool_str (g_hash_table_lookup (metadata, TOTEM_PL_PARSER_FIELD_PLAYING));
subtitle_uri = g_hash_table_lookup (metadata, TOTEM_PL_PARSER_FIELD_SUBTITLE_URI);
- if (playing) {
- starttime = g_hash_table_lookup (metadata, TOTEM_PL_PARSER_FIELD_STARTTIME);
- if (starttime != NULL) {
- g_free (playlist->priv->starttime);
- playlist->priv->starttime = g_strdup (starttime);
- }
+ starttime_str = g_hash_table_lookup (metadata, TOTEM_PL_PARSER_FIELD_STARTTIME);
+ starttime = totem_pl_parser_parse_duration (starttime_str, FALSE);
+ starttime = MAX (starttime, 0);
+ if (starttime_str != NULL && playing) {
+ g_free (playlist->priv->starttime);
+ playlist->priv->starttime = g_strdup (starttime_str);
}
- totem_playlist_add_one_mrl (playlist, uri, title, content_type, subtitle_uri, playing);
+ totem_playlist_add_one_mrl (playlist, uri, title, content_type, subtitle_uri, starttime, playing);
}
static gboolean
@@ -893,6 +895,7 @@ totem_playlist_add_one_mrl (TotemPlaylist *playlist,
const char *display_name,
const char *content_type,
const char *subtitle_uri,
+ gint64 starttime,
gboolean playing)
{
GtkListStore *store;
@@ -912,7 +915,7 @@ totem_playlist_add_one_mrl (TotemPlaylist *playlist,
uri = totem_create_full_path (mrl);
- g_debug ("totem_playlist_add_one_mrl (): %s %s %s %s %s\n", filename_for_display, uri, display_name, subtitle_uri, playing ? "true" : "false");
+ g_debug ("totem_playlist_add_one_mrl (): %s %s %s %s %"G_GINT64_FORMAT " %s\n", filename_for_display, uri, display_name, subtitle_uri, starttime, playing ? "true" : "false");
store = GTK_LIST_STORE (playlist->priv->model);
@@ -944,6 +947,7 @@ totem_playlist_add_one_mrl (TotemPlaylist *playlist,
FILE_MONITOR_COL, monitor,
MOUNT_COL, mount,
MIME_TYPE_COL, content_type,
+ STARTTIME_COL, starttime,
-1);
g_free (escaped_filename);
@@ -986,7 +990,7 @@ static gboolean
handle_parse_result (TotemPlParserResult res, TotemPlaylist *playlist, const gchar *mrl, const gchar *display_name, GError **error)
{
if (res == TOTEM_PL_PARSER_RESULT_UNHANDLED)
- return totem_playlist_add_one_mrl (playlist, mrl, display_name, NULL, NULL, FALSE);
+ return totem_playlist_add_one_mrl (playlist, mrl, display_name, NULL, NULL, 0, FALSE);
if (res == TOTEM_PL_PARSER_RESULT_ERROR) {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
_("The playlist ā€œ%sā€ could not be parsed. It might be damaged."), display_name ? display_name : mrl);
@@ -1109,7 +1113,7 @@ totem_playlist_add_mrl_sync (TotemPlaylist *playlist,
gtk_tree_path_free (playlist->priv->current);
playlist->priv->current = gtk_tree_model_get_path (playlist->priv->model, &iter);
- *starttime = parse_starttime (playlist);
+ *starttime = parse_starttime (playlist->priv->starttime);
g_clear_pointer (&playlist->priv->starttime, g_free);
break;