changeset 679:958b309147b0

display gst pipeline state on the web gui Ignore-this: a4aed9827021e178701c6ea79be3e87a
author drewp@bigasterisk.com
date Tue, 21 Jun 2011 00:24:48 +0000
parents 9eed31bf435b
children ad17b0a09f5c
files light9/ascoltami/index.html light9/ascoltami/player.py light9/ascoltami/webapp.py
diffstat 3 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/light9/ascoltami/index.html	Tue Jun 21 00:02:57 2011 +0000
+++ b/light9/ascoltami/index.html	Tue Jun 21 00:24:48 2011 +0000
@@ -18,6 +18,7 @@
     <div>Time: <span id="currentTime"/></div>
     <div>Left: <span id="leftTime"/></div>
     <div>Until autostop: <span id="leftAutoStopTime"/></div>
+    <div>States: <span id="states"/></div>
     <div class="timeRow">
       <div id="timeSlider"/>
     </div>
@@ -55,6 +56,7 @@
 	    $("#leftTime").text((data.duration - data.t).toFixed(1));
 	    $("#leftAutoStopTime").text(
 		Math.max(0, data.duration - times.post - data.t).toFixed(1));
+	    $("#states").text(JSON.stringify(data.state));
 	    currentDuration = data.duration;
 	    $("#timeSlider").slider({value: data.t,
 				     max: data.duration});
--- a/light9/ascoltami/player.py	Tue Jun 21 00:02:57 2011 +0000
+++ b/light9/ascoltami/player.py	Tue Jun 21 00:24:48 2011 +0000
@@ -118,6 +118,13 @@
             return self.playbin.query_duration(gst.FORMAT_TIME)[0] / gst.SECOND
         except gst.QueryError:
             return 0
+
+    def states(self):
+        """json-friendly object describing the interesting states of
+        the player nodes"""
+        success, state, pending = self.playbin.get_state(timeout=0)
+        return {"current": {"name":state.value_nick},
+                "pending": {"name":state.value_nick}}
         
     def pause(self):
         self.pipeline.set_state(gst.STATE_PAUSED)
--- a/light9/ascoltami/webapp.py	Tue Jun 21 00:02:57 2011 +0000
+++ b/light9/ascoltami/webapp.py	Tue Jun 21 00:24:48 2011 +0000
@@ -40,7 +40,9 @@
             "started" : player.playStartTime,
             "duration" : player.duration(),
             "playing" : player.isPlaying(),
-            "t" : player.currentTime()})
+            "t" : player.currentTime(),
+            "state" : player.states(),
+            })
 
     def POST(self):
         """