ocarina/trunk/ocarina.py

64 lines
1.4 KiB
Python

import gobject
import sys
import thread
from song import Song
from cline import CLine
from duration import Duration
#import cmnds
class main:
def __init__(self,argv):
if len(argv) == 0:
print "python ocarina.py /path/to/song/"
self.commands = CLine()
self.registerCmnds()
lines = ["test","testing","final test"]
self.commands.printLines(lines)
self.song = Song(argv[0],self.quit,self.commands.printLines)
self.song.play()
# Start main loop as a thread so we can get bus calls and use command line
gobject.threads_init()
mainloop = gobject.MainLoop()
thread.start_new_thread(mainloop.run,())
def quit(self):
self.commands.quit()
print "Quitting..."
sys.exit(0)
def registerCmnds(self):
self.commands.register("quit",self.quit,"Exit ocarina")
self.commands.register("exit",self.quit,"Exit ocarina")
self.commands.register("foo",self.foo,"a test function")
self.commands.register("play",self.play,"Play current song")
self.commands.register("pause",self.pause,"Pause current song")
self.commands.register("time",self.time,"Display running time")
def foo(self):
self.commands.printLine("foo...")
def play(self):
self.song.play()
def pause(self):
self.song.pause()
def time(self):
cur = self.song.curTime()
tot = self.song.length
self.commands.printLine(cur.toStr()+" / "+tot.toStr())
if __name__=='__main__':main(sys.argv[1:])