Changeset - 77c39b6e71ab
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 20 years ago 2005-06-17 23:41:08
drewp@bigasterisk.com
new asco xmlrpc commands to seek/pause
1 file changed with 13 insertions and 1 deletions:
0 comments (0 inline, 0 general)
bin/ascoltami
Show inline comments
 
@@ -5,25 +5,24 @@
 
""" a separate player program from Semprini.py. name means 'listen to
 
me' in italian.
 

	
 
features and limitations:
 

	
 
  xmlrpc interface for:
 
    getting the current time in the playing song
 
    requesting what song is playing
 
    saying what song should play
 

	
 
todo:
 

	
 
presong and postsong silence
 

	
 
"""
 

	
 
from __future__ import division,nested_scopes
 

	
 
from optparse import OptionParser
 
import os,math,time
 
import Tkinter as tk
 

	
 
from twisted.internet import reactor,tksupport
 
from twisted.internet.error import CannotListenError
 
from twisted.web import xmlrpc, server
 
@@ -40,24 +39,37 @@ class XMLRPCServe(xmlrpc.XMLRPC):
 
        xmlrpc.XMLRPC.__init__(self)
 
        self.player=player
 

	
 
    def xmlrpc_echo(self,x):
 
        return x
 

	
 
    def xmlrpc_playfile(self,musicfilename):
 
        self.player.play(musicfilename)
 
        return 'ok'
 
    def xmlrpc_stop(self):
 
        self.player.state.set('stop')
 
        return 'ok'
 
    def xmlrpc_seek_to(self,t):
 
        self.player.seek_to(t)
 
        return 'ok'
 
    def xmlrpc_seekplay_or_pause(self,t):
 
        """either seek to t and play; or pause. this is the
 
        curvecalc click-play interface"""
 
        if self.player.state.get() == "play":
 
            self.player.pause()
 
            return 'paused'
 
        else:
 
            self.player.seek_to(t)
 
            self.player.play()
 
            return 'playing'
 
    def xmlrpc_gettime(self):
 
        """returns seconds from start of song"""
 
        return float(self.player.smoothCurrentTime())
 
    def xmlrpc_songlength(self):
 
        """song length, in seconds"""
 
        return float(self.player.total_time.get())
 
    def xmlrpc_songname(self):
 
        """song filename, or None"""
 
        return self.player.filename_var.get() or "No song"
 

	
 
class Player:
 
    """semprini-style access to mpd. in here is where we add the padding"""
0 comments (0 inline, 0 general)