[totem] chapters: Fix output of timestamps from the chapters plugin



commit 5b86b43cb62d94a22827134bf565a859e32ebcf1
Author: Philip Withnall <philip tecnocode co uk>
Date:   Thu Apr 14 18:20:07 2011 +0100

    chapters: Fix output of timestamps from the chapters plugin
    
    It wasn't outputting timestamps that it could read for any times greater
    than 1 minute.
    
    This fixes it to output correct NPT-formatted timestamps for all times,
    which it can read.
    
    Closes: bgo#647513

 src/plugins/chapters/totem-cmml-parser.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/chapters/totem-cmml-parser.c b/src/plugins/chapters/totem-cmml-parser.c
index 07a761e..01cacba 100644
--- a/src/plugins/chapters/totem-cmml-parser.c
+++ b/src/plugins/chapters/totem-cmml-parser.c
@@ -805,6 +805,9 @@ totem_cmml_write_file_async (TotemCmmlAsyncData *data)
 		guint8		*stream;
 		TotemCmmlClip	*clip;
 		gchar		start_buf[G_ASCII_DTOSTR_BUF_SIZE];
+		gchar		*start_string;
+		gint		hours, minutes;
+		gdouble		seconds;
 
 		clip = (TotemCmmlClip *) cur_clip->data;
 		time_start = ((gdouble) clip->time_start) / 1000;
@@ -818,8 +821,13 @@ totem_cmml_write_file_async (TotemCmmlAsyncData *data)
 		if (G_UNLIKELY (res < 0))
 			break;
 
-		res = xmlTextWriterWriteAttribute (writer, (const xmlChar *) "start",
-		                                   (const xmlChar *) g_ascii_dtostr (start_buf, sizeof (buf), time_start));
+		/* Format the time in NPT format (npt:%d:%d:%f) */
+		hours = ((glong) time_start) / 3600;
+		minutes = ((glong) time_start % 3600) / 60;
+		seconds = time_start - ((glong) hours * 3600) - ((glong) minutes * 60);
+		start_string = g_strdup_printf ("npt:%d:%d:%s", hours, minutes, g_ascii_dtostr (start_buf, sizeof (buf), seconds));
+		res = xmlTextWriterWriteAttribute (writer, (const xmlChar *) "start", (const xmlChar *) start_string);
+		g_free (start_string);
 		if (G_UNLIKELY (res < 0))
 			break;
 



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