Changeset - 41aa6895b3e6
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 17 years ago 2008-06-10 05:15:22
drewp@bigasterisk.com
ascoltami: local pympd import; cmdline ui
1 file changed with 4 insertions and 1 deletions:
0 comments (0 inline, 0 general)
bin/ascoltami
Show inline comments
 
@@ -14,64 +14,65 @@ features and limitations:
 

	
 

	
 
setup:
 

	
 
get mpd root path correct
 

	
 
run mpd that's been modified to give precise times:
 
  dash(pts/21):/my/dl/modified/mpd% src/mpd --no-daemon
 

	
 
tell it to scan
 
  mpc update
 
  (mpc listall   to check)
 
  
 
run ascoltami
 

	
 

	
 
todo:
 

	
 

	
 
"""
 

	
 
from __future__ import division,nested_scopes
 

	
 
from optparse import OptionParser
 
import os,math,time
 
import sys, os,math,time
 
from rdflib import URIRef
 
import Tkinter as tk
 
import logging
 
log = logging.getLogger()
 
log.setLevel(logging.DEBUG)
 

	
 
from twisted.internet import reactor,tksupport
 
from twisted.internet.error import CannotListenError
 
from twisted.web import xmlrpc, server
 

	
 
import run_local
 
from light9 import networking, showconfig, wavelength
 
from light9.namespaces import L9, MUS
 
from light9.uihelpers import toplevelat
 

	
 
sys.path.append("/home/drewp/projects/pympd_0")
 
from pympd import Mpd
 

	
 
appstyle={'fg':'white','bg':'black'}
 

	
 
def shortSongPath(song, all):
 
    prefixlen = len(os.path.commonprefix(all))
 
    # include to the last os.sep- dont crop path elements in the middle
 
    prefixlen = all[0].rfind(os.sep)+1 
 

	
 
    return os.path.splitext(song[prefixlen:])[0]
 
    
 

	
 
class XMLRPCServe(xmlrpc.XMLRPC):
 
    def __init__(self,player):
 
        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):
 
@@ -481,48 +482,50 @@ class ControlButtons(tk.Frame):
 
        for name, button in self.statebuttons.items():
 
            if name == 'pause' and state not in ('stop', 'pause'):
 
                name = 'play'
 

	
 
            if state == name: # name gets changed sometimes for 'pause' -- see right above
 
                button['bg'] = colors.get(name, 'black')
 
            else:
 
                button['bg'] = 'black'
 
        self.goButton.updateStatus()
 

	
 
############################
 

	
 

	
 

	
 
def main():
 
    global graph
 
    parser = OptionParser()
 
    parser.add_option('--show',
 
        help='show URI, like http://light9.bigasterisk.com/show/dance2008')
 
    graph = showconfig.getGraph()
 
    (options, songfiles) = parser.parse_args()
 

	
 
    if len(songfiles)<1:
 
        graph = showconfig.getGraph()
 
        if not options.show:
 
            raise ValueError("missing --show http://...")
 
        playList = graph.value(URIRef(options.show), L9['playList'])
 
        songs = list(graph.items(playList))
 
    else:
 
        raise NotImplementedError("don't know how to make rdf song nodes from cmdline song paths")
 

	
 

	
 
    root=tk.Tk()
 
    root.wm_title("ascoltami")
 
    toplevelat("ascoltami", root)
 
    root.config(bg="black")
 
    player=Player()
 

	
 
    songlist = buildsonglist(root, graph, songs, player)
 
    songlist.pack(fill='both',exp=1)
 

	
 
    seeker = Seeker(root, player)
 
    
 
    goRow = tk.Frame(root)
 
    tk.Label(goRow, text="Go button action",
 
             font='arial 9', **appstyle).pack(side='left', fill='both')
 
    goStatus = tk.Label(goRow, font='arial 12 bold', **appstyle)
 
    goStatus.config(bg='#800000', fg='white', relief='ridge')
 
    goStatus.pack(side='left', expand=True, fill='x')
 

	
0 comments (0 inline, 0 general)