81 lines
1.3 KiB
Python
81 lines
1.3 KiB
Python
# Bryan Schumaker (11/23/2010)
|
|
|
|
import prefs
|
|
import audio
|
|
import libsaria
|
|
from libsaria import path
|
|
from libsaria import sources
|
|
from libsaria import callbacks
|
|
|
|
expand = path.expand
|
|
exists = path.exists
|
|
|
|
pause_after = False
|
|
prefs.init("libsaria.random", False)
|
|
|
|
def pick_next():
|
|
global pause_after
|
|
file = sources.next()
|
|
if file != None:
|
|
load(file)
|
|
if pause_after == True:
|
|
pause()
|
|
else:
|
|
play()
|
|
pause_after = False
|
|
|
|
def catch_eos(*args):
|
|
libsaria.sources.inc_count()
|
|
pick_next()
|
|
|
|
def next():
|
|
pick_next()
|
|
|
|
def play():
|
|
audio.play()
|
|
|
|
def pause():
|
|
audio.pause()
|
|
|
|
def playing():
|
|
return audio.get_state() == audio.gst.STATE_PLAYING
|
|
|
|
def do_pause_after(*args):
|
|
global pause_after
|
|
pause_after = True
|
|
|
|
def toggle_play():
|
|
if audio.get_state() == audio.gst.STATE_PAUSED:
|
|
play()
|
|
else:
|
|
pause()
|
|
|
|
def stop():
|
|
audio.stop()
|
|
|
|
def seek_forward():
|
|
libsaria.audio.seek(5)
|
|
|
|
def seek_backward():
|
|
libsaria.audio.seek(-5)
|
|
|
|
def set_volume(prcnt):
|
|
audio.set_volume(prcnt)
|
|
callbacks.set_volume(prcnt)
|
|
|
|
def set_rand(rand):
|
|
prefs.set("libsaria.random", rand)
|
|
|
|
def set_like(like=None):
|
|
sources.set_attr("like", like)
|
|
callbacks.like_song(like)
|
|
|
|
def get_like():
|
|
return sources.all_attrs()["like"]
|
|
|
|
def load(file):
|
|
file = expand(file)
|
|
if not exists(file):
|
|
return False
|
|
audio.load_file(file)
|