gst-renderer: Correctly handle EOS
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Tue, 13 Oct 2009 22:06:11 +0000 (01:06 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Mon, 19 Oct 2009 13:32:41 +0000 (16:32 +0300)
src/plugins/gst-renderer/rygel-gst-video-window.vala

index 9c0ba76..7d7edda 100644 (file)
@@ -107,7 +107,9 @@ public class Rygel.GstVideoWindow : GLib.Object {
         this.playbin = ElementFactory.make ("playbin2", null);
         assert (this.playbin != null);
 
-        this.playbin.eos += this.eos_cb;
+        // Bus handler
+        var bus = this.playbin.get_bus ();
+        bus.add_watch (this.bus_handler);
     }
 
     public static GstVideoWindow get_default () {
@@ -118,10 +120,6 @@ public class Rygel.GstVideoWindow : GLib.Object {
         return video_window;
     }
 
-    private void eos_cb (Element playbin) {
-        this.playback_state = "STOPPED";
-    }
-
     public bool seek (string time) {
         debug ("Seeking to %s.", time);
         return this.playbin.seek (1.0,
@@ -132,6 +130,16 @@ public class Rygel.GstVideoWindow : GLib.Object {
                                   Gst.SeekType.NONE,
                                   -1);
     }
+
+    private bool bus_handler (Bus     bus,
+                              Message message) {
+        if (message.type == MessageType.EOS) {
+            debug ("EOS");
+            this.playback_state = "STOPPED";
+        }
+
+        return true;
+    }
 }
 
 // Helper class for converting between Gstreamer time units and string