[clutter-gst] player: Add an option to loop the video



commit 354b1958b765bad02093b7af47759860c144855b
Author: Damien Lespiau <damien lespiau intel com>
Date:   Thu Sep 1 00:20:12 2011 +0100

    player: Add an option to loop the video

 examples/video-player.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/examples/video-player.c b/examples/video-player.c
index de8108b..c749c1d 100644
--- a/examples/video-player.c
+++ b/examples/video-player.c
@@ -53,6 +53,7 @@ typedef struct _VideoApp
 static void show_controls (VideoApp *app, gboolean vis);
 
 static gboolean opt_fullscreen = FALSE;
+static gboolean opt_loop = FALSE;
 
 static GOptionEntry options[] =
 {
@@ -63,6 +64,13 @@ static GOptionEntry options[] =
     "Start the player in fullscreen",
     NULL },
 
+  { "loop",
+    'l', 0,
+    G_OPTION_ARG_NONE,
+    &opt_loop,
+    "Start the video again once reached the EOS",
+    NULL },
+
   { NULL }
 };
 
@@ -311,6 +319,17 @@ tick (GObject      *object,
                           SEEK_H);
 }
 
+static void
+on_video_texture_eos (ClutterMedia *media,
+                      VideoApp     *app)
+{
+  if (opt_loop)
+    {
+      clutter_media_set_progress (media, 0.0);
+      clutter_media_set_playing (media, TRUE);
+    }
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -364,6 +383,11 @@ main (int argc, char *argv[])
                                     CLUTTER_GST_VIDEO_TEXTURE (app->vtexture),
                                     CLUTTER_GST_SEEK_FLAG_ACCURATE);
 
+  g_signal_connect (app->vtexture,
+                    "eos",
+                    G_CALLBACK (on_video_texture_eos),
+                    app);
+
   g_signal_connect (stage,
                     "allocation-changed",
                     G_CALLBACK (on_stage_allocation_changed),



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