2010-11-23 20:37:24 -05:00
|
|
|
# Bryan Schumaker (11/23/2010)
|
|
|
|
|
2011-04-30 10:48:59 -04:00
|
|
|
import prefs
|
2011-04-30 12:06:48 -04:00
|
|
|
import audio
|
2011-05-26 09:02:06 -04:00
|
|
|
import libsaria
|
2011-05-25 21:07:53 -04:00
|
|
|
from libsaria import path
|
|
|
|
from libsaria import sources
|
2011-04-30 13:05:22 -04:00
|
|
|
from libsaria import callbacks
|
2010-11-27 15:38:48 -05:00
|
|
|
|
2011-05-25 21:07:53 -04:00
|
|
|
expand = path.expand
|
|
|
|
exists = path.exists
|
2010-11-23 20:37:24 -05:00
|
|
|
|
2010-12-17 23:00:45 -05:00
|
|
|
pause_after = False
|
2011-04-30 10:48:59 -04:00
|
|
|
prefs.init("libsaria.random", False)
|
2010-12-17 23:00:45 -05:00
|
|
|
|
2010-12-05 17:11:41 -05:00
|
|
|
def pick_next():
|
2010-12-17 23:00:45 -05:00
|
|
|
global pause_after
|
2011-05-07 18:14:12 -04:00
|
|
|
file = sources.next()
|
2011-05-15 10:26:38 -04:00
|
|
|
if file != None:
|
|
|
|
load(file)
|
2010-12-23 10:17:14 -05:00
|
|
|
if pause_after == True:
|
2010-12-17 23:00:45 -05:00
|
|
|
pause()
|
2010-12-23 10:17:14 -05:00
|
|
|
else:
|
|
|
|
play()
|
|
|
|
pause_after = False
|
2010-12-05 17:11:41 -05:00
|
|
|
|
|
|
|
def catch_eos(*args):
|
2011-05-24 08:02:18 -04:00
|
|
|
libsaria.sources.inc_count()
|
2011-04-30 13:17:28 -04:00
|
|
|
pick_next()
|
2010-12-05 17:11:41 -05:00
|
|
|
|
|
|
|
def next():
|
2011-04-30 13:17:28 -04:00
|
|
|
pick_next()
|
2010-11-23 20:37:24 -05:00
|
|
|
|
|
|
|
def play():
|
2011-04-30 12:37:31 -04:00
|
|
|
audio.play()
|
2010-11-23 20:44:37 -05:00
|
|
|
|
|
|
|
def pause():
|
2011-04-30 12:42:27 -04:00
|
|
|
audio.pause()
|
2010-11-23 20:50:57 -05:00
|
|
|
|
2010-12-27 19:00:27 -05:00
|
|
|
def playing():
|
|
|
|
return audio.get_state() == audio.gst.STATE_PLAYING
|
|
|
|
|
2010-12-17 23:00:45 -05:00
|
|
|
def do_pause_after(*args):
|
|
|
|
global pause_after
|
|
|
|
pause_after = True
|
|
|
|
|
2010-12-15 22:26:45 -05:00
|
|
|
def toggle_play():
|
|
|
|
if audio.get_state() == audio.gst.STATE_PAUSED:
|
|
|
|
play()
|
|
|
|
else:
|
|
|
|
pause()
|
|
|
|
|
2010-11-23 20:50:57 -05:00
|
|
|
def stop():
|
2011-04-30 12:45:27 -04:00
|
|
|
audio.stop()
|
2010-11-23 21:10:22 -05:00
|
|
|
|
2010-12-16 22:08:26 -05:00
|
|
|
def seek_forward():
|
2011-04-30 13:17:28 -04:00
|
|
|
libsaria.audio.seek(5)
|
2010-12-16 22:08:26 -05:00
|
|
|
|
|
|
|
def seek_backward():
|
2011-04-30 13:17:28 -04:00
|
|
|
libsaria.audio.seek(-5)
|
2010-12-16 22:08:26 -05:00
|
|
|
|
2010-11-23 21:10:22 -05:00
|
|
|
def set_volume(prcnt):
|
2011-04-30 13:08:05 -04:00
|
|
|
audio.set_volume(prcnt)
|
|
|
|
callbacks.set_volume(prcnt)
|
2010-11-23 21:10:22 -05:00
|
|
|
|
2010-12-23 09:51:09 -05:00
|
|
|
def set_rand(rand):
|
2011-04-30 10:48:59 -04:00
|
|
|
prefs.set("libsaria.random", rand)
|
2010-12-05 17:11:41 -05:00
|
|
|
|
2010-12-17 23:33:05 -05:00
|
|
|
def set_like(like=None):
|
2011-04-30 13:05:22 -04:00
|
|
|
sources.set_attr("like", like)
|
|
|
|
callbacks.like_song(like)
|
2010-12-18 11:03:25 -05:00
|
|
|
|
|
|
|
def get_like():
|
2011-06-17 20:23:32 -04:00
|
|
|
return sources.all_attrs()["like"]
|
2010-12-17 23:33:05 -05:00
|
|
|
|
2010-12-05 17:11:41 -05:00
|
|
|
def load(file):
|
|
|
|
file = expand(file)
|
|
|
|
if not exists(file):
|
|
|
|
return False
|
2011-04-30 12:55:48 -04:00
|
|
|
audio.load_file(file)
|