[rygel] examples: Add python examples for introspection
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] examples: Add python examples for introspection
- Date: Tue, 19 Aug 2014 19:37:04 +0000 (UTC)
commit 6f12d67cdaa8ef6abe6f9db503076e89d36afed4
Author: Jens Georg <mail jensge org>
Date: Sat Jul 12 12:52:17 2014 +0200
examples: Add python examples for introspection
Signed-off-by: Jens Georg <mail jensge org>
examples/gi/example-renderer.py | 56 +++++++++++++++++++++++++++++++++++++++
examples/gi/example-server.py | 22 +++++++++++++++
2 files changed, 78 insertions(+), 0 deletions(-)
---
diff --git a/examples/gi/example-renderer.py b/examples/gi/example-renderer.py
new file mode 100755
index 0000000..5fa6029
--- /dev/null
+++ b/examples/gi/example-renderer.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+
+from gi.repository import RygelCore as rc
+from gi.repository import RygelRenderer as rr
+from gi.repository import GObject
+
+class ExamplePlayer(GObject.Object, rr.MediaPlayer):
+ __gtype_name = "RygelPythonExamplePlayer"
+
+ # Abstract properties
+ playback_state = GObject.property (type = str, default = "NO_MEDIA_PRESENT")
+ allowed_playback_speeds = GObject.property (type = GObject.TYPE_STRV, default = ["1"])
+ playback_speed = GObject.property (type = str, default = "1")
+ uri = GObject.property (type = str, default = "")
+ volume = GObject.property (type = float, default = 1.0)
+ duration = GObject.property (type = GObject.TYPE_INT64, default = 0)
+ size = GObject.property (type = GObject.TYPE_INT64, default = 0)
+ metadata = GObject.property (type = str, default = None)
+ mime_type = GObject.property (type = str, default = "")
+ can_seek = GObject.property (type = bool, default = False)
+ can_seek_bytes = GObject.property (type = bool, default = False)
+ content_features = GObject.property (type = str, default = None)
+ position = GObject.property (type = GObject.TYPE_INT64, default = 0)
+ byte_position = GObject.property (type = GObject.TYPE_INT64, default = 0)
+
+ # Abstract methods
+ def do_seek(self, position):
+ return False
+
+ def do_seek_bytes(self, position):
+ return False
+
+ def do_get_protocols(self):
+ return ["http"], 1
+
+ def do_get_mime_types(self):
+ val = ["image/jpeg"]
+ print ("Mime types: ", val)
+ return val, len(val)
+
+ # Property setters/getters
+ def do_get_volume(self):
+ return self.volume;
+
+ def do_set_volume(self, _volume):
+ self.volume = _volume;
+
+ def __init__(self):
+ GObject.Object.__init__(self)
+
+d = rr.MediaRenderer (title = "DLNA renderer from Python!",
+ player = ExamplePlayer())
+
+d.add_interface ("lo")
+
+GObject.MainLoop().run()
diff --git a/examples/gi/example-server.py b/examples/gi/example-server.py
new file mode 100755
index 0000000..86b28f9
--- /dev/null
+++ b/examples/gi/example-server.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+
+from gi.repository import GObject
+from gi.repository import RygelCore as rc
+from gi.repository import RygelServer as rs
+
+rs.MediaEngine.init ()
+
+c = rs.SimpleContainer.root ("DLNA from Python!")
+i = rs.VideoItem (id = "0001",
+ parent = c,
+ title = "Test Video",
+ upnp_class = rs.ImageItem.UPNP_CLASS)
+i.set_property ("mime-type", "video/ogv")
+c.add_child_item (i)
+
+d = rs.MediaServer (title = "DLNA server from Python!",
+ root_container = c,
+ capabilities = rc.PluginCapabilities.NONE)
+d.add_interface ("eth0")
+
+GObject.MainLoop().run()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]