ocarina/html/controls.py

53 lines
1.1 KiB
Python

# Bryan Schumaker (11/18/2010)
import libsaria.audio
import libsaria.sources
import ocarina
controls = libsaria.controls
play = controls.play
pause = controls.pause
stop = controls.stop
next = controls.next
attrs = libsaria.sources.get_attrs
load_id = libsaria.sources.library.load_id
playing = controls.playing
forward = controls.seek_forward
rewind = controls.seek_backward
def to_html(wfile, args):
action = args["a"]
ret = False
if action == "play":
ret = play()
elif action == "pause":
ret = pause()
elif action == "stop":
ret = stop()
elif action == "next":
ret = next()
elif action == "forward":
ret = forward()
elif action == "rewind":
ret = rewind()
elif action == "version":
ret = ocarina.__vers__
elif action == "uptime":
ret = ocarina.now() - ocarina.__start__
elif action == "title":
ret = attrs("title")
elif action == "album":
ret = "from %s" % attrs("album")
elif action == "artist":
ret = "by %s" % attrs("artist")
elif action == "playing":
ret = playing()
elif action == "load":
load_id(int(args['id']))
play()
#else:
# print action, args
wfile.write(str(ret))