ocarina/src/core/next.py

56 lines
1.1 KiB
Python

# This is a simple test plugin, to make sure everything is working
__author__="bjschuma"
__date__ ="$Jan 2, 2010 1:18:37 PM$"
global name, app, type, path, opt
name = "next"
app = "ocarina"
type = "core"
path = ""
opt = []
from bt.message import write
from bt.file import join
import settings
from tools import database
from manager import manager
def next():
cur = settings.get("current")
database.open()
count = database.count("track")
database.close()
if cur == count:
return 0
return cur+1
# Called every time the plugin is enabled
def open():
settings.set("current",0)
settings.set("next",next)
pass
# Called every time the plugin is stopped
def close():
pass
# Called when the plugin needs to perform some action
def run(args=None):
id = settings.get("next")()
curlib = str(settings.get("curlib"))
database.open()
a = database.select("path","library","id="+curlib).fetchone()[0]
b = database.select("path","track","id="+str(id)).fetchone()[0]
database.close()
settings.set("current",id)
manager.run("load",([a+b]))
manager.run("play")