ocarina/libsaria/collection/__init__.py

51 lines
856 B
Python

# Bryan Schumaker (8/8/2010)
__all__ = ["collection"]
import libsaria
import tagpy
call = libsaria.event.call
exists = libsaria.path.exists
expand = libsaria.path.expand
FileRef = tagpy.FileRef
LIBRARY = 0
PLAYLIST = 1
QUEUE = 2
import collection
library = collection.Collection()
cur_lib_id = -1
def new_source(path, bg=True):
global library
path = expand(path)
if not exists(path):
return 0
return call("NEWSOURCE", library.scan, path)
def walk_library():
global library
for track in library:
yield track
def lib_get_attr(id, attr):
global library
if id >= 0:
return library.get_attr(id, attr)
return None
def lib_play_id(id):
global cur_lib_id
cur_lib_id = id
filepath = lib_get_attr(id, "filepath")
libsaria.music.load(filepath)
libsaria.music.play()
def lib_get_cur_id():
global cur_lib_id
return cur_lib_id