Can choose a random song
This commit is contained in:
parent
788eb841f7
commit
e5dfd01a0d
|
@ -20,6 +20,7 @@ import settings
|
|||
|
||||
# Called every time the plugin is enabled
|
||||
def open():
|
||||
settings.set("curlib",-1)
|
||||
pass
|
||||
|
||||
|
||||
|
@ -45,6 +46,7 @@ def library(args):
|
|||
# Insert the library into the database
|
||||
database.open()
|
||||
next = database.count('library')
|
||||
settings.replace("curlib",next)
|
||||
database.insert('library',(next,name,root) )
|
||||
database.close()
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ def close():
|
|||
def run(args=None):
|
||||
if args == None:
|
||||
return
|
||||
gstreamer.close()
|
||||
if len(args) == 1:
|
||||
gstreamer.load(args[0])
|
||||
else:
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
# 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")
|
|
@ -22,12 +22,10 @@ from manager import manager
|
|||
from tools import database
|
||||
|
||||
|
||||
#settings.set("ocarina", join(settings.get("user"),".ocarina2") )
|
||||
settings.set("user", join(settings.get("user"),".ocarina2"))
|
||||
manager.restoresession()
|
||||
mkdir(settings.get("user"))
|
||||
manager.restoresession()
|
||||
bt.proc.setname("Ocarina2")
|
||||
#from tools import library
|
||||
|
||||
|
||||
# Called every time the plugin is enabled
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
# This is a simple test plugin, to make sure everything is working
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Jan 2, 2010 1:14:04 PM$"
|
||||
|
||||
|
||||
global name, app, type, path, opt
|
||||
name = "rand"
|
||||
app = "ocarina"
|
||||
type = "core"
|
||||
path = ""
|
||||
opt = []
|
||||
|
||||
from bt.message import write
|
||||
from tools import database
|
||||
import random
|
||||
import settings
|
||||
|
||||
|
||||
def next():
|
||||
count = database.count("track")
|
||||
return random.randint(0,count)
|
||||
|
||||
|
||||
# Called every time the plugin is enabled
|
||||
def open():
|
||||
settings.set("random",False)
|
||||
pass
|
||||
|
||||
|
||||
# Called every time the plugin is stopped
|
||||
def close():
|
||||
pass
|
||||
|
||||
|
||||
# Called when the plugin needs to perform some action
|
||||
def run(args=None):
|
||||
if args==None or len(args)==0:
|
||||
settings.replace("random",not settings.get("random"))
|
||||
random = settings.get("random")
|
||||
if random == True:
|
||||
settings.set("next",next)
|
||||
else:
|
||||
settings.pop("next")
|
||||
elif args[0]=="?":
|
||||
write(str(settings.get("random")))
|
|
@ -106,7 +106,7 @@ def commit():
|
|||
|
||||
def init():
|
||||
global db
|
||||
db = join(settings.get("ocarina"),"ocarina.db")
|
||||
db = join(settings.get("user"),"ocarina.db")
|
||||
dbExists = checkPath(db)
|
||||
open()
|
||||
if dbExists == False:
|
||||
|
|
Loading…
Reference in New Issue