[snappy] ui: switch to display time left
- From: Luis de Bethencourt <luisbg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [snappy] ui: switch to display time left
- Date: Sat, 5 Oct 2013 21:10:22 +0000 (UTC)
commit 40c2edd7bf6738a4d750699efc934a519a22340a
Author: Luis de Bethencourt <luis debethencourt com>
Date: Sat Oct 5 17:10:07 2013 -0400
ui: switch to display time left
docs/keyboard_controls | 2 ++
src/user_interface.c | 37 +++++++++++++++++++++++++++++--------
src/user_interface.h | 1 +
3 files changed, 32 insertions(+), 8 deletions(-)
---
diff --git a/docs/keyboard_controls b/docs/keyboard_controls
index 4021cb8..fbf456e 100644
--- a/docs/keyboard_controls
+++ b/docs/keyboard_controls
@@ -27,6 +27,8 @@ v - toggle subtitles
_ - cycle through available video streams
j - cycle through available subtitle streams
+o - display playback time/display time left
+
r - rotate video
. - frame step foward
diff --git a/src/user_interface.c b/src/user_interface.c
index c1ef848..ccd5987 100644
--- a/src/user_interface.c
+++ b/src/user_interface.c
@@ -45,7 +45,7 @@ static void load_controls (UserInterface * ui);
static void new_video_size (UserInterface * ui, gfloat width, gfloat height,
gfloat * new_width, gfloat * new_height);
static gboolean penalty_box (gpointer data);
-static gchar *position_ns_to_str (gint64 nanoseconds);
+static gchar *position_ns_to_str (UserInterface * ui, gint64 nanoseconds);
static void progress_timing (UserInterface * ui);
static gboolean progress_update_text (gpointer data);
static gboolean progress_update_seekbar (gpointer data);
@@ -437,15 +437,28 @@ event_cb (ClutterStage * stage, ClutterEvent * event, UserInterface * ui)
break;
}
+ case CLUTTER_o:
+ {
+ // switch display to time left of the stream
+ ui->duration_str_fwd_direction = !ui->duration_str_fwd_direction;
+
+ handled = TRUE;
+ break;
+ }
+
case CLUTTER_less:
{
interface_play_next_or_prev (ui, FALSE);
+
+ handled = TRUE;
break;
}
case CLUTTER_greater:
{
interface_play_next_or_prev (ui, TRUE);
+
+ handled = TRUE;
break;
}
@@ -529,7 +542,10 @@ event_cb (ClutterStage * stage, ClutterEvent * event, UserInterface * ui)
} else if (actor == ui->video_stream_toggle) {
cycle_streams (ui->engine, STREAM_VIDEO);
- }
+
+ } else if (actor == ui->control_pos) {
+ ui->duration_str_fwd_direction = !ui->duration_str_fwd_direction;
+ }
}
handled = TRUE;
@@ -966,11 +982,14 @@ penalty_box (gpointer data)
}
static gchar *
-position_ns_to_str (gint64 nanoseconds)
+position_ns_to_str (UserInterface * ui, gint64 nanoseconds)
{
gint64 seconds;
gint hours, minutes;
+ if (!ui->duration_str_fwd_direction)
+ nanoseconds = ui->engine->media_duration - nanoseconds;
+
seconds = nanoseconds / GST_SECOND;
hours = seconds / SEC_IN_HOUR;
seconds = seconds - (hours * SEC_IN_HOUR);
@@ -1011,13 +1030,14 @@ progress_update_text (gpointer data)
gint64 pos;
if (ui->media_duration != engine->media_duration) {
- ui->duration_str = position_ns_to_str (engine->media_duration);
progress_timing (ui);
}
pos = query_position (engine);
- duration_str = g_strdup_printf (" %s | %s", position_ns_to_str (pos),
- ui->duration_str);
+
+ duration_str = g_strdup_printf (" %s | %s",
+ position_ns_to_str (ui, pos), ui->duration_str);
+ g_print("%s\n", duration_str);
clutter_text_set_text (CLUTTER_TEXT (ui->control_pos), duration_str);
}
}
@@ -1384,7 +1404,7 @@ interface_load_uri (UserInterface * ui, gchar * uri)
clutter_text_set_text (CLUTTER_TEXT (ui->control_title), ui->filename);
}
- ui->duration_str = position_ns_to_str (ui->engine->media_duration);
+ ui->duration_str = position_ns_to_str (ui, ui->engine->media_duration);
ui->media_width = ui->engine->media_width;
ui->media_height = ui->engine->media_height;
ui->windowed_width = ui->media_width;
@@ -1552,6 +1572,7 @@ interface_start (UserInterface * ui, gchar * uri)
ui->controls_showing = FALSE;
ui->keep_showing_controls = FALSE;
ui->penalty_box_active = FALSE;
+ ui->duration_str_fwd_direction = TRUE;
ui->controls_timeout = -1;
ui->seek_width = ui->stage_width / SEEK_WIDTH_RATIO;
@@ -1560,7 +1581,7 @@ interface_start (UserInterface * ui, gchar * uri)
ui->progress_id = -1;
ui->title_length = TITLE_LENGTH;
ui->media_duration = -1;
- ui->duration_str = position_ns_to_str (ui->engine->media_duration);
+ ui->duration_str = position_ns_to_str (ui, ui->engine->media_duration);
clutter_actor_set_size (CLUTTER_ACTOR (ui->stage), ui->stage_width,
ui->stage_height);
diff --git a/src/user_interface.h b/src/user_interface.h
index 0c9c35f..65345a4 100644
--- a/src/user_interface.h
+++ b/src/user_interface.h
@@ -75,6 +75,7 @@ struct _UserInterface
gboolean controls_showing, keep_showing_controls;
gboolean blind, fullscreen, hide, penalty_box_active, tags;
gboolean subtitles_available;
+ gboolean duration_str_fwd_direction;
gint title_length, controls_timeout, progress_id;
guint media_width, media_height;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]