Changeset - 54c863b2553e
[Not reviewed]
default
0 1 0
Drew Perttula - 14 years ago 2011-06-16 07:10:56
drewp@bigasterisk.com
CC don't run musicPlayer.path as often
Ignore-this: f7185b8741062f7c14d9fe0793a8138d
1 file changed with 5 insertions and 3 deletions:
0 comments (0 inline, 0 general)
bin/curvecalc
Show inline comments
 
#!/usr/bin/python
 

	
 
"""
 
now launches like this:
 
% bin/curvecalc http://light9.bigasterisk.com/show/dance2007/song1
 

	
 

	
 

	
 
todo: curveview should preserve more objects, for speed maybe
 

	
 
"""
 
from __future__ import division
 
import time,textwrap,math,random,os,optparse
 
import time,textwrap,math,random,os,optparse, urllib2
 
import Tix as tk
 
try:
 
    from dispatch import dispatcher
 
except ImportError:
 
    import louie as dispatcher 
 
from twisted.internet import reactor,tksupport
 
import jsonlib, restkit
 
import twisted
 
from twisted.web.client import Agent
 
from twisted.internet.protocol import Protocol
 
from twisted.internet.defer import Deferred     
 
from zope.interface import implements
 
@@ -68,28 +68,30 @@ class StringProducer(object):
 

	
 
    def pauseProducing(self):
 
        pass
 

	
 
    def stopProducing(self):
 
        pass
 

	
 
class Music:
 
    def __init__(self):
 
        self.recenttime=0
 
        self.player = Agent(reactor)
 
        dispatcher.connect(self.seekplay_or_pause,"music seek")
 
        self.timePath = networking.musicPlayer.path("time")
 
        
 
    def current_time(self):
 
        """return deferred which gets called with the current time"""
 
        d = self.player.request("GET", networking.musicPlayer.path("time"))
 
        """return deferred which gets called with the current
 
        time. This gets called really often"""
 
        d = self.player.request("GET", self.timePath)
 
        d.addCallback(self._timeReturned)
 
        return d
 

	
 
    def _timeReturned(self, response):
 
        done = Deferred()
 
        done.addCallback(self._bodyReceived)
 
        response.deliverBody(GatherJson(done))
 
        return done
 

	
 
    def _bodyReceived(self, data):
 
        dispatcher.send("input time",val=data['t'])
 
        return data['t'] # pass along to the real receiver
0 comments (0 inline, 0 general)