Changeset - c2faa69099e6
[Not reviewed]
default
0 4 0
drewp@bigasterisk.com - 12 years ago 2013-06-12 23:47:12
drewp@bigasterisk.com
asco: display update frequency and dim when updates stop. run slower updates on tablets and phones
Ignore-this: 2439d0f540c9eae00c4f18e26411c100
4 files changed with 50 insertions and 14 deletions:
0 comments (0 inline, 0 general)
bin/ascoltami2
Show inline comments
 
@@ -42,6 +42,8 @@ if __name__ == "__main__":
 
        help='show URI, like http://light9.bigasterisk.com/show/dance2008', default=showconfig.showUri())
 
    parser.add_option("-v", "--verbose", action="store_true",
 
                      help="logging.DEBUG")
 
    parser.add_option("--twistedlog", action="store_true",
 
                      help="twisted logging")
 
    (options, args) = parser.parse_args()
 

	
 
    log.setLevel(logging.DEBUG if options.verbose else logging.INFO)
 
@@ -51,6 +53,9 @@ if __name__ == "__main__":
 
            
 
    graph = showconfig.getGraph()
 
    app = App(graph, URIRef(options.show))
 
    if options.twistedlog:
 
        from twisted.python import log as twlog
 
        twlog.startLogging(sys.stderr)
 
    reactor.listenTCP(networking.musicPlayer.port, makeWebApp(app))
 
    log.info("listening on %s" % networking.musicPlayer.port)
 
    reactor.run()
light9/ascoltami/index.html
Show inline comments
 
@@ -14,15 +14,17 @@
 
    <h1>ascoltami on ${host}</h1>
 
    <div class="songs"/>
 

	
 
    <div>Song: <span id="currentSong"/></div>
 
    <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 class="dimStalled">
 
      <div>Song: <span id="currentSong"/></div>
 
      <div>Time: <span id="currentTime"/></div>
 
      <div>Left: <span id="leftTime"/></div>
 
      <div>Until autostop: <span id="leftAutoStopTime"/></div>
 
      <div>Update freq: requested <span id="updateReq"/>, actual <span id="updateActual"/></div>
 
      <div>States: <span id="states"/></div>
 
      <div class="timeRow">
 
        <div id="timeSlider"/>
 
      </div>
 
    </div>
 

	
 
    <div class="commands">
 
      <button id="cmd-stop" class="playMode">Stop<div class="key">s</div></button>
 
      <button id="cmd-play" class="playMode">Play <div class="key">p</div></button>
 
@@ -33,16 +35,20 @@
 
      <button id="cmd-out0">Output 0</button>
 
      <button id="cmd-out1">Output 1</button>
 
    </div>
 

	
 
    
 
    <p>Running on <span id="nav"/></p>
 
    todo: display next action
 
    <p><button onclick="window.open('/', '_blank', 'scrollbars=1,resizable=1,titlebar=0,location=0')">reopen this in a simpler window</button></p>
 
    
 
    todo: go button actions, display next action
 
    <a href="">reload</a>
 
    <p><a href="">reload</a></p>
 

	
 
<script type="text/javascript">
 
// <![CDATA[
 
$(function () {
 

	
 
    $("#nav").text(navigator.userAgent);
 
    var updateFreq = (navigator.userAgent.indexOf("Linux") != -1) ? 10 : 2;
 
    $("#updateReq").text(updateFreq);
 

	
 
    var times = { // need to get these from server
 
	intro: 4,
 
	post: 4
 
@@ -145,12 +151,34 @@
 
	window.mozRequestAnimationFrame || 
 
	window.webkitRequestAnimationFrame;
 

	
 
    var recentUpdates = [];
 
    function onUpdate() {
 
        recentUpdates.push(+new Date());
 
        recentUpdates = recentUpdates.slice(Math.max(recentUpdates.length - 5, 0));
 
        refreshUpdateFreqs();
 
    }
 

	
 
    function refreshUpdateFreqs() {
 
        if (recentUpdates.length > 1) {
 
          if (+new Date() - recentUpdates[recentUpdates.length - 1] > 1000) {
 
            $("#updateActual").text("(stalled)");
 
            $(".dimStalled").addClass("stalled");
 
            return;
 
          }
 

	
 
          var avgMs = (recentUpdates[recentUpdates.length - 1] - recentUpdates[0]) / (recentUpdates.length - 1);
 
          $("#updateActual").text(Math.round(1000 / avgMs));
 
        }
 
    }
 
    setInterval(refreshUpdateFreqs, 2000);
 

	
 
    function updateLoop() {
 
	var whenDone = function () {
 
	    setTimeout(function () { 
 
		raf(updateLoop);
 
	    }, 50);
 
	    }, 1000 / updateFreq);
 
	};
 
        onUpdate();
 
	updateCurrent(whenDone);
 
    }
 
    updateLoop();
light9/ascoltami/webapp.py
Show inline comments
 
@@ -5,7 +5,7 @@ from light9.namespaces import L9
 
from light9.showconfig import getSongsFromShow, songOnDisk
 
from rdflib import URIRef
 
from web.contrib.template import render_genshi
 
render = render_genshi([sibpath(__file__, ".")])
 
render = render_genshi([sibpath(__file__, ".")], auto_reload=True)
 

	
 
try:
 
    import sys
static/style.css
Show inline comments
 
@@ -55,4 +55,7 @@ body {
 
}
 
.timeRow {
 
    margin: 14px;
 
}
 
.stalled {
 
    opacity: .5;
 
}
 
\ No newline at end of file
0 comments (0 inline, 0 general)