[rygel/rygel-0-16] playbin: Only report duration if known



commit 5a338f68e636c34f1b7b3becd1d7c1f84cab8a3d
Author: Jens Georg <jensg openismus com>
Date:   Mon Nov 12 22:29:35 2012 +0100

    playbin: Only report duration if known

 src/librygel-renderer/rygel-playbin-player.vala |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/librygel-renderer/rygel-playbin-player.vala b/src/librygel-renderer/rygel-playbin-player.vala
index ad2351f..8a834ba 100644
--- a/src/librygel-renderer/rygel-playbin-player.vala
+++ b/src/librygel-renderer/rygel-playbin-player.vala
@@ -80,6 +80,7 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
                                         "video/x-xvid",
                                         "video/x-ms-wmv" };
     private static Player player;
+    bool duration_hint;
 
     public dynamic Element playbin { get; private set; }
 
@@ -305,6 +306,9 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
     private void bus_handler (Gst.Bus bus,
                               Message message) {
         switch (message.type) {
+        case MessageType.DURATION:
+            this.duration_hint = true;
+        break;
         case MessageType.STATE_CHANGED:
             if (message.src == this.playbin) {
                 State old_state, new_state, pending;
@@ -313,14 +317,18 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
                                              out new_state,
                                              out pending);
                 if (old_state == State.READY && new_state == State.PAUSED) {
-                    this.notify_property ("duration");
+                    if (this.duration_hint) {
+                        this.notify_property ("duration");
+                        this.duration_hint = false;
+                    }
+
                     if (this.uri_update_hint) {
                         this.uri_update_hint = false;
                         string uri = this.playbin.uri;
                         if (this._uri != uri) {
                             // uri changed externally
                             this._uri = this.playbin.uri;
-                            this.notify_property("uri");
+                            this.notify_property ("uri");
                             this.metadata = this.generate_basic_didl ();
                         }
                     }
@@ -408,6 +416,7 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
     }
 
     private void setup_playbin () {
+        this.duration_hint = false;
         // Needed to get "Stop" events from the playbin.
         // We can do this because we have a bus watch
         this.playbin.auto_flush_bus = false;



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