Changeset - acdad1f7b75f
[Not reviewed]
default
0 2 0
Drew Perttula - 6 years ago 2019-06-02 11:34:36
drewp@bigasterisk.com
some metrics from asco
Ignore-this: 1df3b55be5136d09e3d7a65c203b4761
2 files changed with 7 insertions and 0 deletions:
0 comments (0 inline, 0 general)
light9/ascoltami/player.py
Show inline comments
 
@@ -3,15 +3,19 @@
 
alternate to the mpd music player, for ascoltami
 
"""
 

	
 
import time, logging, traceback
 
from gi.repository import Gst
 
from twisted.internet import task
 
from greplin import scales
 

	
 
log = logging.getLogger()
 

	
 
stats = scales.collection('/player',
 
                          scales.RecentFpsStat('currentTimeFps'),
 
)
 

	
 
class Player(object):
 

	
 
    def __init__(self, autoStopOffset=4, onEOS=None):
 
        """autoStopOffset is the number of seconds before the end of
 
        song before automatically stopping (which is really pausing).
 
@@ -133,12 +137,13 @@ class Player(object):
 
        try:
 
            open(songPath[len("file://"):], 'rb').read()
 
        except IOError as e:
 
            log.error("couldn't preload %s, %r", songPath, e)
 
            raise
 

	
 
    @stats.currentTimeFps.rate()
 
    def currentTime(self):
 
        success, cur = self.playbin.query_position(Gst.Format.TIME)
 
        if not success:
 
            return 0
 
        return cur / Gst.SECOND
 

	
light9/ascoltami/webapp.py
Show inline comments
 
import json, socket, subprocess, os
 

	
 
from cyclone import template
 
from rdflib import URIRef
 
import cyclone.web
 
from greplin.scales.cyclonehandler import StatsHandler
 

	
 
from cycloneerr import PrettyErrorHandler
 
from light9.namespaces import L9
 
from light9.showconfig import getSongsFromShow, songOnDisk
 

	
 
_songUris = {}  # locationUri : song
 
@@ -163,8 +164,9 @@ def makeWebApp(app):
 
        (r"/time", timeResource),
 
        (r"/song", songResource),
 
        (r"/songs", songs),
 
        (r"/seekPlayOrPause", seekPlayOrPause),
 
        (r"/output", output),
 
        (r"/go", goButton),
 
        (r'/stats/(.*)', StatsHandler, {'serverName': 'ascoltami'}),
 
    ],
 
                                   app=app)
0 comments (0 inline, 0 general)