examples: Simulate image rendering in vala example
authorJens Georg <jensg@openismus.com>
Thu, 10 Oct 2013 11:05:30 +0000 (13:05 +0200)
committerJens Georg <jensg@openismus.com>
Thu, 10 Oct 2013 11:05:30 +0000 (13:05 +0200)
examples/renderer-plugins/vala/example-player-vala.vala
examples/renderer-plugins/vala/example-renderer-plugin-vala.vala

index 4768c67..6771e43 100644 (file)
@@ -54,6 +54,25 @@ public class Rygel.Example.PlayerVala : GLib.Object, Rygel.MediaPlayer {
 
         set {
             this._playback_state = value;
+            if (this._playback_state == "PLAYING") {
+                Idle.add (() => {
+                    uint8[] data;
+                    try {
+                        var f = File.new_for_uri (this.uri);
+                        f.load_contents (null, out data, null);
+                    } catch (Error err) {
+                        warning ("Failed: %s", err.message);
+                    }
+
+                    Timeout.add_seconds (60, () => {
+                        this.playback_state = "EOS";
+
+                        return false;
+                    });
+
+                    return false;
+                });
+            }
         }
     }
 
@@ -92,6 +111,9 @@ public class Rygel.Example.PlayerVala : GLib.Object, Rygel.MediaPlayer {
              * rygel -g 5
              */
             debug ("URI set to %s.", value);
+            if (this._playback_state == "EOS") {
+                this.playback_state = "PLAYING";
+            }
         }
     }
 
index 26b029e..53f6303 100644 (file)
@@ -59,6 +59,15 @@ public class Rygel.Example.RendererPluginVala : Rygel.MediaRendererPlugin {
         base (NAME, TITLE, DESCRIPTION);
     }
 
+    public override void constructed () {
+        base.constructed ();
+        var l = new List<Rygel.Renderer.DLNAProfile> ();
+        l.prepend (new Rygel.Renderer.DLNAProfile ("JPEG_SM", "image/jpeg"));
+        l.prepend (new Rygel.Renderer.DLNAProfile ("MP3", "audio/mpeg"));
+
+        this.supported_profiles = l;
+    }
+
     public override MediaPlayer? get_player () {
         return Example.PlayerVala.get_default ();
     }