renderer: Check player if it can do time-seek
authorJens Georg <jensg@openismus.com>
Sat, 1 Dec 2012 21:52:38 +0000 (22:52 +0100)
committerJens Georg <jensg@openismus.com>
Thu, 6 Dec 2012 07:08:53 +0000 (08:08 +0100)
examples/renderer-plugins/C/example-player.c
examples/renderer-plugins/vala/example-player-vala.vala
src/librygel-renderer-gst/rygel-playbin-player.vala
src/librygel-renderer/rygel-media-player.vala
src/librygel-renderer/rygel-player-controller.vala
src/plugins/mpris/rygel-mpris-player.vala

index 25c4cfb..430fae8 100644 (file)
@@ -25,6 +25,7 @@ enum  {
   RYGEL_EXAMPLE_PLAYER_PLAYBACK_STATE,
   RYGEL_EXAMPLE_PLAYER_URI,
   RYGEL_EXAMPLE_PLAYER_MIME_TYPE,
+  RYGEL_EXAMPLE_PLAYER_CAN_SEEK,
   RYGEL_EXAMPLE_PLAYER_METADATA,
   RYGEL_EXAMPLE_PLAYER_CONTENT_FEATURES,
   RYGEL_EXAMPLE_PLAYER_VOLUME,
@@ -192,6 +193,14 @@ rygel_example_player_class_init (RygelExamplePlayerClass *klass) {
       G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
 
   g_object_class_install_property (gobject_class,
+    RYGEL_EXAMPLE_PLAYER_CAN_SEEK,
+    g_param_spec_boolean ("can-seek",
+      "can-seek",
+      "can-seek",
+      FALSE,
+      G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
+
+  g_object_class_install_property (gobject_class,
     RYGEL_EXAMPLE_PLAYER_CONTENT_FEATURES,
     g_param_spec_string ("content-features",
       "content-features",
@@ -434,6 +443,9 @@ _rygel_example_player_get_property (GObject *object, guint property_id, GValue *
     case RYGEL_EXAMPLE_PLAYER_POSITION:
       g_value_set_int64 (value, rygel_media_player_get_position (base));
       break;
+    case RYGEL_EXAMPLE_PLAYER_CAN_SEEK:
+      g_value_set_boolean (value, FALSE);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
index 04a5a04..a79817b 100644 (file)
@@ -99,6 +99,8 @@ public class Rygel.Example.PlayerVala : GLib.Object, Rygel.MediaPlayer {
         }
     }
 
+    public bool can_seek { get { return false; } }
+
     private string _content_features = "";
     public string? content_features {
         owned get {
index e7388fd..2616699 100644 (file)
@@ -206,6 +206,13 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
         }
     }
 
+    public bool can_seek {
+        get {
+            return this.transfer_mode != TRANSFER_MODE_INTERACTIVE &&
+                   ! this.mime_type.has_prefix ("image/");
+        }
+    }
+
     private string _content_features = "";
     private ProtocolInfo protocol_info;
     public string? content_features {
index 81a0acd..68ecd0a 100644 (file)
@@ -54,6 +54,9 @@ public interface Rygel.MediaPlayer : GLib.Object {
     /// The mime-type of the currently-playing media
     public abstract string? mime_type { owned get; set; }
 
+    /// The current media supports time-based seeking
+    public abstract bool can_seek { get; }
+
     /**
      * The contents of the contentFeatures.dlna.org HTTP header,
      * containing the 4th field of the protocol info for the current
index 2ac1c35..4f4be7c 100644 (file)
@@ -77,16 +77,28 @@ internal class Rygel.PlayerController : Object {
 
     public string current_transport_actions {
         owned get {
+            string actions = null;
             switch (this._playback_state) {
                 case "PLAYING":
                 case "TRANSITIONING":
-                    return "Stop,Seek,X_DLNA_SeekTime,Pause";
+                    actions = "Stop,Seek,Pause";
+                    break;
                 case "STOPPED":
                 case "PAUSED_PLAYBACK":
-                    return "Play,Seek,X_DLNA_SeekTime";
+                    actions = "Play,Seek";
+                    break;
                 default:
-                    return "";
+                    break;
             }
+            if (actions != null && this.player.can_seek) {
+                actions += ",X_DLNA_SeekTime";
+            }
+
+            if (actions == null) {
+                return "";
+            }
+
+            return actions;
         }
     }
 
index 80e9569..df12c1e 100644 (file)
@@ -87,6 +87,8 @@ public class Rygel.MPRIS.Player : GLib.Object, Rygel.MediaPlayer {
     public string? metadata { owned get; set; }
     public string? content_features { owned get; set; }
 
+    public bool can_seek { get { return true; } }
+
     public double volume {
         get {
             return this.actual_player.volume;